Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDES2CREATECLIN

SDES2CREATECLIN.m

Go to the documentation of this file.
SDES2CREATECLIN ;ALB/MGD/BLB,BWF,TJB - SDES2 CREATE CLINIC MAIN DRIVER ;SEPT 20,2023
 ;;5.3;Scheduling;**853,860,871,885,893**;Aug 13, 1993;Build 6
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ; The SDCONTEXT array is controlled by the Acheron application and its fields are
 ; needed for the storage of the required auditing information.
 ;
 ; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
 ; SDCONTEXT("PATIENT DFN") = The DFN/IEN of the target patient from the calling application.
 ; SDCONTEXT("PATIENT ICN") = The ICN of the target patient from the calling application.
 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
 ; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
 ;
 ; The SDCLINIC array contains all of the Clinic specific input variables needed
 ; to add and configure a clinic.
 ;
 ; Required Input Variables
 ; ========================
 ; Field #   Array Element
 ;   2001    SDCLINIC("ALLOWABLE CONSECUTIVE NO-SHOWS")
 ;     61    SDCLINIC("DIRECT PATIENT SCHEDULING")
 ;      8    SDCLINIC("PRIMARY AMIS")
 ;    .01    SDCLINIC("NAME")
 ;     62    SDCLINIC("DISPLAY APPOINTMENTS")
 ;     63    SDCLINIC("VETERAN SELF-CANCEL")
 ;   1917    SDCLINIC("DISPLAY INCREMENTS PER HOUR")
 ;    3.5    SDCLINIC("DIVISION")
 ;     20    SDCLINIC("E-CHECKIN ALLOWED")
 ;   1912    SDCLINIC("LENGTH OF APPOINTMENT")
 ;   2002    SDCLINIC("MAX DAYS FUTURE BOOKING")
 ;   2504    SDCLINIC("MEETS AT FACILITY")
 ;   2502    SDCLINIC("NON-COUNT")
 ;   1918    SDCLINIC("OVERBOOKS/DAY MAX")
 ;     21    SDCLINIC("PRE-CHECKIN ALLOWED")
 ; 2000.5    SDCLINIC("REQUIRE ACTION PROFILES")
 ;      9    SDCLINIC("SERVICE")
 ;
 ; Optional Input Variables
 ; Field #   Array Element
 ; ========================
 ;    1      SDCLINIC("ABBREVIATION")
 ; 2802      SDCLINIC("ADMIN INPATIENT MEDS")
 ; 2511      SDCLINIC("APPOINTMENT CANCELLATION LETTER")
 ;   24      SDCLINIC("ASK CHECK IN/OUT")
 ; 2510      SDCLINIC("CLINIC CANCELLATION LETTER")
 ; 2503      SDCLINIC("CREDIT AMIS")
 ; 2507      SDCLINIC("DEFAULT APPOINTMENT TYPE")
 ; 2801      SDCLINIC("DEFAULT TO PC PRACTITIONER")
 ; 2700/.01  SDCLINIC("DIAGNOSIS",DIAGNOSISCODE)
 ; 2700/.02  SDCLINIC("DIAGNOSIS",DIAGNOSISCODE,"DEFAULT")
 ; 1914      SDCLINIC("HOUR CLINIC DISPLAY BEGINS")
 ; 2508      SDCLINIC("NO-SHOW LETTER")
 ;   60      SDCLINIC("PATIENT FRIENDLY NAME")
 ;   10      SDCLINIC("PHYSICAL LOCATION")
 ; 2509      SDCLINIC("PRE-APPOINTMENT LETTER")
 ; 1916      SDCLINIC("PRINCIPAL CLINIC")
 ; 2501/.01  SDCLINIC("PRIVILEGED USER",IEN)
 ; 2500      SDCLINIC("PROHIBIT ACCESS TO CLINIC")
 ; 2600/.01  SDCLINIC("PROVIDER",VPROVIEN)
 ; 2600/.02  SDCLINIC("PROVIDER",VPROVIEN,"DEFAULT")
 ; 2000      SDCLINIC("REQUIRE X-RAY")
 ; 1918.5    SDCLINIC("SCHEDULE ON HOLIDAYS")
 ; 1910/.01  SDCLINIC("SPECIAL INSTRUCTIONS",NUMBER)= "(null value) |SPECIAL INSTRUCTION TEXT UP TO 80 CHARACTERS" FOR ADDITION
 ;           SDCLINIC("SPECIAL INSTRUCTIONS",NUMBER)= "INSTRUCTION ID|SPECIAL INSTRUCTION TEXT UP TO 80 CHARACTERS" FOR EDIT
 ;   99      SDCLINIC("TELEPHONE")
 ; 99.1      SDCLINIC("TELEPHONE EXTENSION")
 ; 1913      SDCLINIC("VARIABLE APPOINTMENT LENGTH")
 ;   30      SDCLINIC("WORKLOAD VALIDATION")
 ;
 Q
 ;
 ; RPC: SDES2 CREATE CLINIC
 ;
CREATECLINIC(SDRETURN,SDCONTEXT,SDCLINIC) ; Add a new clinic to the HOSPITAL LOCATION  file (#44)
 ;
 N SDERRORS,SDJSONERRORS,SDFDA,SDCLINRETURN,SDFILEDATA,SDCLINICIEN,SDRESULTS
 ;
 ; Can't send in @ for Create Clinic
 D CHECKFORDEL^SDES2UTIL(.SDERRORS,.SDCONTEXT)
 I $D(SDERRORS) S SDJSONERRORS("CreateClinic",1)="" M SDJSONERRORS=SDERRORS D BUILDJSON^SDES2JSON(.SDRETURN,.SDJSONERRORS) Q
 ;
 D CHECKFORDEL^SDES2UTIL(.SDERRORS,.SDCLINIC)
 I $D(SDERRORS) S SDJSONERRORS("CreateClinic",1)="" M SDJSONERRORS=SDERRORS D BUILDJSON^SDES2JSON(.SDRETURN,.SDJSONERRORS) Q
 ;
 D CHECKFORDELMULT^SDES2UTIL(.SDERRORS,.SDCLINIC)
 I $D(SDERRORS) S SDJSONERRORS("CreateClinic",1)="" M SDJSONERRORS=SDERRORS D BUILDJSON^SDES2JSON(.SDRETURN,.SDJSONERRORS) Q
 ;
 D VALCONTEXT^SDES2VALCONTEXT(.SDERRORS,.SDCONTEXT)
 I $D(SDERRORS) S SDJSONERRORS("CreateClinic",1)="" M SDJSONERRORS=SDERRORS D BUILDJSON^SDES2JSON(.SDRETURN,.SDJSONERRORS) Q
 ;
 D VALCLINIC^SDES2VALCRTCLIN1(.SDERRORS,.SDCLINIC,.SDFILEDATA)
 I $D(SDERRORS) S SDJSONERRORS("CreateClinic",1)="" M SDJSONERRORS=SDERRORS D BUILDJSON^SDES2JSON(.SDRETURN,.SDJSONERRORS) Q
 ;
 D CREATEFDAARRAY(.SDFILEDATA,.SDFDA)
 ;
 D FILECLINIC(.SDERRORS,.SDFDA,.SDCLINICIEN)
 I $D(SDERRORS) M SDJSONERRORS=SDERRORS D BUILDJSON^SDES2JSON(.SDRETURN,.SDJSONERRORS)
 ;
 Q:'$G(SDCLINICIEN)
 ; Add multiple fields after creation of clinic
 D ADDMULTIPLES(.SDERRORS,.SDFILEDATA,.SDCLINICIEN)
 ;
 D ADDHASH2CLIN^SDES2CLINUT(SDCLINICIEN)
 ;
 D ADDRESOURCE^SDES2CLINUT(SDCLINICIEN)
 ;
 I +$G(SDCLINICIEN) S SDCLINRETURN("CreateClinic","IEN")=SDCLINICIEN
 D BUILDJSON^SDES2JSON(.SDRETURN,.SDCLINRETURN)
 Q
 ;
CREATEFDAARRAY(FILEDATA,SDFDA) ;
 ; Clinic Data - Required Fields
 I $G(FILEDATA("ALLOWABLE CONSECUTIVE NO-SHOWS"))'="" S SDFDA(44,"+1,",2001)=FILEDATA("ALLOWABLE CONSECUTIVE NO-SHOWS")
 I $G(FILEDATA("DIRECT PATIENT SCHEDULING"))'="" S SDFDA(44,"+1,",61)=FILEDATA("DIRECT PATIENT SCHEDULING")
 I $G(FILEDATA("DISPLAY APPOINTMENTS"))'="" S SDFDA(44,"+1,",62)=FILEDATA("DISPLAY APPOINTMENTS")
 I $G(FILEDATA("DISPLAY INCREMENTS PER HOUR"))'="" S SDFDA(44,"+1,",1917)=FILEDATA("DISPLAY INCREMENTS PER HOUR")
 I $G(FILEDATA("DIVISION"))'="" S SDFDA(44,"+1,",3.5)=FILEDATA("DIVISION")
 I $G(FILEDATA("E-CHECKIN ALLOWED"))'="" S SDFDA(44,"+1,",20)=FILEDATA("E-CHECKIN ALLOWED")
 I $G(FILEDATA("LENGTH OF APPOINTMENT"))'="" S SDFDA(44,"+1,",1912)=FILEDATA("LENGTH OF APPOINTMENT")
 I $G(FILEDATA("MAX DAYS FUTURE BOOKING"))'="" S SDFDA(44,"+1,",2002)=FILEDATA("MAX DAYS FUTURE BOOKING")
 I $G(FILEDATA("NAME"))'="" S SDFDA(44,"+1,",.01)=FILEDATA("NAME")
 I $G(FILEDATA("NON-COUNT"))'="" S SDFDA(44,"+1,",2502)=FILEDATA("NON-COUNT")
 I $G(FILEDATA("OVERBOOKS/DAY MAX"))'="" S SDFDA(44,"+1,",1918)=FILEDATA("OVERBOOKS/DAY MAX")
 I $G(FILEDATA("PRE-CHECKIN ALLOWED"))'="" S SDFDA(44,"+1,",21)=FILEDATA("PRE-CHECKIN ALLOWED")
 I $G(FILEDATA("PRIMARY AMIS"))'="" S SDFDA(44,"+1,",8)=FILEDATA("PRIMARY AMIS")
 I $G(FILEDATA("REQUIRE ACTION PROFILES"))'="" S SDFDA(44,"+1,",2000.5)=FILEDATA("REQUIRE ACTION PROFILES")
 I $G(FILEDATA("SERVICE"))'="" S SDFDA(44,"+1,",9)=FILEDATA("SERVICE")
 S SDFDA(44,"+1,",2.1)=$$FIND1^DIC(40.9,,,"CLINIC") ;Type Extension pointer to 40.9
 ; Optional Fields
 I $G(FILEDATA("ABBREVIATION"))'="" S SDFDA(44,"+1,",1)=FILEDATA("ABBREVIATION")
 I $G(FILEDATA("ADMIN INPATIENT MEDS"))'="" S SDFDA(44,"+1,",2802)=FILEDATA("ADMIN INPATIENT MEDS")
 I $G(FILEDATA("APPOINTMENT CANCELLATION LETTER"))'="" S SDFDA(44,"+1,",2511)=FILEDATA("APPOINTMENT CANCELLATION LETTER")
 I $G(FILEDATA("ASK CHECK IN/OUT"))'="" S SDFDA(44,"+1,",24)=FILEDATA("ASK CHECK IN/OUT")
 I $G(FILEDATA("CLINIC CANCELLATION LETTER"))'="" S SDFDA(44,"+1,",2510)=FILEDATA("CLINIC CANCELLATION LETTER")
 I $G(FILEDATA("CREDIT AMIS"))'="" S SDFDA(44,"+1,",2503)=FILEDATA("CREDIT AMIS")
 I $G(FILEDATA("DEFAULT APPOINTMENT TYPE"))'="" S SDFDA(44,"+1,",2507)=FILEDATA("DEFAULT APPOINTMENT TYPE")
 I $G(FILEDATA("DEFAULT TO PC PRACTITIONER"))'="" S SDFDA(44,"+1,",2801)=FILEDATA("DEFAULT TO PC PRACTITIONER")
 I $G(FILEDATA("HOUR CLINIC DISPLAY BEGINS"))'="" S SDFDA(44,"+1,",1914)=FILEDATA("HOUR CLINIC DISPLAY BEGINS")
 I $G(FILEDATA("MEETS AT FACILITY"))'="" S SDFDA(44,"+1,",2504)=FILEDATA("MEETS AT FACILITY")
 I $G(FILEDATA("NO-SHOW LETTER"))'="" S SDFDA(44,"+1,",2508)=FILEDATA("NO-SHOW LETTER")
 I $G(FILEDATA("PATIENT FRIENDLY NAME"))'="" S SDFDA(44,"+1,",60)=FILEDATA("PATIENT FRIENDLY NAME")
 I $G(FILEDATA("PBSPID"))'="" S SDFDA(44,"+1,",200)=FILEDATA("PBSPID")
 I $G(FILEDATA("PHYSICAL LOCATION"))'="" S SDFDA(44,"+1,",10)=FILEDATA("PHYSICAL LOCATION")
 I $G(FILEDATA("PRE-APPOINTMENT LETTER"))'="" S SDFDA(44,"+1,",2509)=FILEDATA("PRE-APPOINTMENT LETTER")
 I $G(FILEDATA("PRINCIPAL CLINIC"))'="" S SDFDA(44,"+1,",1916)=FILEDATA("PRINCIPAL CLINIC")
 I $G(FILEDATA("PROHIBIT ACCESS TO CLINIC"))'="" S SDFDA(44,"+1,",2500)=FILEDATA("PROHIBIT ACCESS TO CLINIC")
 I $G(FILEDATA("REQUIRE X-RAY"))'="" S SDFDA(44,"+1,",2000)=FILEDATA("REQUIRE X-RAY")
 I $G(FILEDATA("SCHEDULE ON HOLIDAYS"))'="" S SDFDA(44,"+1,",1918.5)=FILEDATA("SCHEDULE ON HOLIDAYS")
 I $G(FILEDATA("TELEPHONE"))'="" S SDFDA(44,"+1,",99)=FILEDATA("TELEPHONE")
 I $G(FILEDATA("TELEPHONE EXTENSION"))'="" S SDFDA(44,"+1,",99.1)=FILEDATA("TELEPHONE EXTENSION")
 I $G(FILEDATA("VARIABLE APPOINTMENT LENGTH"))'="" S SDFDA(44,"+1,",1913)=FILEDATA("VARIABLE APPOINTMENT LENGTH")
 I $G(FILEDATA("WORKLOAD VALIDATION"))'="" S SDFDA(44,"+1,",30)=FILEDATA("WORKLOAD VALIDATION")
 I $G(FILEDATA("VETERAN SELF-CANCEL"))'="" S SDFDA(44,"+1,",63)=FILEDATA("VETERAN SELF-CANCEL")
 S SDFDA(44,"+1,",2)="C"  ; C:CLINIC
 Q
 ;
FILECLINIC(SDERRORS,SDFILEDATA,SDCLINICIEN) ;
 N SDCLINRET,SDCLINMSG,SDCNT,SDERRNUM
 D UPDATE^DIE("","SDFILEDATA","SDCLINRET","SDCLINMSG")
 I $D(SDCLINMSG) D  Q
 . F SDERRNUM=1:1:$G(SDCLINMSG("DIERR")) D ERRLOG^SDES2JSON(.SDERRORS,464,$G(CLINMSG("DIERR",SDERRNUM,"TEXT",1)))
 K CLINMSG("DIERR")
 S SDCLINICIEN=SDCLINRET(1)
 Q
 ;
ADDMULTIPLES(SDERRORS,SDFILEDATA,SDCLINICIEN) ; Add multiple fields after Clinic creation
 I $D(SDCLINIC("PROVIDER")) D SAVEPROVIDERS^SDES2CLINUT(.SDERRORS,.SDFILEDATA,SDCLINICIEN)
 I $D(SDCLINIC("DIAGNOSIS")) D SAVEDIAG^SDES2CLINUT(.SDERRORS,.SDFILEDATA,SDCLINICIEN)
 I $D(SDCLINIC("PRIVILEGED USER")) D SAVEPRIVUSERS^SDES2CLINUT(.SDERRORS,.SDFILEDATA,SDCLINICIEN)
 I $D(SDCLINIC("SPECIAL INSTRUCTIONS")) D SAVEINSTRUCT^SDES2CLINUT(.SDERRORS,.SDFILEDATA,SDCLINICIEN)
 Q
 ;
ERRLOG(ERNUM,OPTIONALTXT) ;
 D ERRLOG^SDES2JSON(.SDCLINIC,$G(ERNUM),$G(OPTIONALTXT))
 Q