SDES2EDITCLIN ;ALB/BWF,MGD/BLB,BWF,TJB - SDES2 EDIT CLINIC ;JAN 02, 2024
;;5.3;Scheduling;**853,857,864,866,871,885,890,893**;Aug 13, 1993;Build 6
;;Per VHA Directive 6402, this routine should not be modified
;
Q
; Reference to ^DG(40.8 is supported by IA #2295
; Reference to ^DG(40.8 is supported by IA #7024
;
; SDNAME - [TEXT, REQ] Clinic Name (REQUIRED)
; SDABR - [TEXT] ABBREVIATION
; SDPATNAME - [TEXT] PATIENT FRIENDLY NAME
; SDMEETATFAC - [Y/N] CLINIC MEETS AT THIS FACILITY? (Default = Y)
; SDPATSCHED - [Y/N, REQ] ALLOW DIRECT PATIENT SCHEDULING? (REQUIRED)
; SDDISPAPPT - [Y/N, REQ] DISPLAY CLIN APPT TO PATIENTS? (REQUIRED)
; SDSERVICE - [Set of codes, REQ] SERVICE (REQUIRED)
; SDNONCOUNT - [Y/N, REQ] NON-COUNT CLINIC? (Y OR N) (REQUIRED)
; SDDIVISION - [File 40.8] DIVISION (REQUIRED)
; SDAPPTTYP - [File 409.1] DEFAULT APPOINTMENT TYPE
; SDINPATMED - [Y/N] ADMINISTER INPATIENT MEDS?
; SDPHONE - [TEXT] TELEPHONE
; SDREQXRAY - [Y/N] REQUIRE X-RAY FILMS?
; SDREQPROFILE - [Y/N] REQUIRE ACTION PROFILES? (REQUIRED)
; SDNOSHOWLET - [File 407.5] NO SHOW LETTER
; SDPREAPTLET - [File 407.5] PRE-APPOINTMENT LETTER
; SDCANLET - [File 407.5] CLINIC CANCELLATION LETTER
; SDAPTCANLET - [File 407.5] APPT. CANCELLATION LETTER
; SDINOUTTIME - [Y/N] ASK FOR CHECK IN/OUT TIME
; SDPROVIDER - [File 200] PROVIDER
; SDPRACTIONER - [Y/N] DEFAULT TO PC PRACTITIONER?
; SDDIAG - [file 80] DIAGNOSIS
; SDWORKLOAD - [Y/N] WORKLOAD VALIDATION AT CHK OUT
; SDALLOWNOSHW - [NUM, REQ] ALLOWABLE CONSECUTIVE NO-SHOWS (REQUIRED)
; SDMAXFUTBOOK - [NUM, REQ] MAX # DAYS FOR FUTURE BOOKING (REQUIRED)
; SDNOACCESS - [Y/N] PROHIBIT ACCESS TO CLINIC?
; SDLOCATION - [TEXT] PHYSICAL LOCATION
; SDPRINCLINIC - [File 44] PRINCIPAL Clinic
; SDOVBDAYMAX - [NUM, REQ] OVERBOOKS/DAY MAXIMUM (REQUIRED)
; SDSPECINSTRU - [TEXT] SPECIAL INSTRUCTIONS
; SDECHECKIN - [Y/N] E-CHECKIN ALLOWED (REQUIRED)
; SDPRECHECKIN - [Y/N] PRE-CHECKIN ALLOWED (REQUIRED)
; SDVARAPTLNG - [TEXT] VARIABLE APP'NTMENT LENGTH
; PRIAMIS - [NUM, OPT] AMIS Primary Stop Code
; CREDITAMIS - [NUM, OPT] AMIS Credit Stop Code
; CLINIC HASH - [TEXT] SHA-1 Hash value that the calling app has stored
; LENGTH OF APPOINTMENT - APPOINTMENT LENGTH
; VETERAN SELF-CANCEL - "Y" for Yes, "N" for No
;
; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
; 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.
; 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.
;
;
; To delete a single field, set that array element to "@" or ""
; SDCLINIC("FIELD NAME")="@" or SDCLINIC("FIELD NAME")=""
; SDCLINIC("CLINIC IEN")=CLINIC IEN IEN of the clinic in file 44 - Hospital location
; SDCLINIC("NAME")=CLINIC NAME FREE TEXT 2-30 characters (Required)
; SDCLINIC("ABBREVIATION")=ABBREVIATION FREE TEXT 1-7 characters
; SDCLINIC("PATIENT FRIENDLY NAME") FREE TEXT 1-80 characters
; SDCLINIC("MEETS AT FACILITY") Y/N for (YES/NO) (Required)
; SDCLINIC("DIRECT PATIENT SCHEDULING") Y/N for (YES/NO)
; SDCLINIC("DISPLAY APPOINTMENTS") Y/N for (YES/NO)
; SDCLINIC("SERVICE") SET OF CODES (M/S/P/R/N/0)
; SDCLINIC("NON-COUNT") Y/N for (YES/NO)
; SDCLINIC("DIVISION") POINTER TO MEDICAL CENTER DIVISION FILE (#40.8)
; SDCLINIC("DEFAULT APPOINTMENT TYPE") POINTER TO APPOINTMENT TYPE FILE (#409.1)
; SDCLINIC("ADMIN INPATIENT MEDS") 'Y' for 'Yes', blank/NULL for 'No'
; SDCLINIC("TELEPHONE") FREE TEXT 3-13 characters
; SDCLINIC("TELEPHONE EXTENSION") FREE TEXT 1-26 characters
; SDCLINIC("REQUIRE X-RAY") 'Y' for 'Yes', null for No
; SDCLINIC("REQUIRE ACTION PROFILES") Y/N for (YES/NO)
; SDCLINIC("NO-SHOW LETTER") LETTER NAME OR IEN POINTER TO LETTER FILE (#407.5)
; SDCLINIC("PRE-APPOINTMENT LETTER") LETTER NAME OR IEN POINTER TO LETTER FILE (#407.5)
; SDCLINIC("CLINIC CANCELLATION LETTER") LETTER NAME OR IEN POINTER TO LETTER FILE (#407.5)
; SDCLINIC("APPOINTMENT CANCELLATION LETTER") LETTER NAME OR IEN POINTER TO LETTER FILE (#407.5)
; SDCLINIC("ASK CHECK IN/OUT") Y/N for (YES/NO)
; SDCLINIC("DEFAULT TO PC PRACTITIONER") Y/N for (YES/NO)
; SDCLINIC("WORKLOAD VALIDATION") Y/N for (YES/NO)
; SDCLINIC("ALLOWABLE CONSECUTIVE NO-SHOWS") NUMBER 0-999
; SDCLINIC("MAX DAYS FUTURE BOOKING") NUMBER 11-999
; SDCLINIC("PROHIBIT ACCESS TO CLINIC") 'Y' for 'Yes'
; SDCLINIC("PHYSICAL LOCATION") FREE TEXT (1-25)
; SDCLINIC("PRINCIPAL CLINIC") POINTER to the Hospital location file (#44)
; SDCLINIC("OVERBOOKS/DAY MAX") NUMBER 0-9999
; SDCLINIC("E-CHECKIN ALLOWED") Y/N for (YES/NO)
; SDCLINIC("PRE-CHECKIN ALLOWED") Y/N for (YES/NO)
; SDCLINIC("VARIABLE APPOINTMENT LENGTH") 'Y' - for Variable appointment length, Null for not variable
; SDCLINIC("PRIMARY AMIS") NUMERIC AMIS CODE (1-999)
; SDCLINIC("CREDIT AMIS") NUMERIC AMIS CODE (1-999)
; SDCLINIC("INCLUDE ON FILE ROOM LISTS") Y/N for (YES/NO)
; SDCLINIC("SCHEDULE ON HOLIDAYS") 'Y' for 'Yes'
; SDCLINIC("LENGTH OF APPOINTMENT") LENGTH OF APPOINTMENT
; SDCLINIC("DISPLAY INCREMENTS PER HOUR") DISPLAY INCREMENTS PER HOUR
; SDCLINIC("CLINIC HASH") [TEXT] SHA-1 Hash value that the calling app has stored
; SDCLINIC("VETERAN SELF-CANCEL") 'Y' for 'YES', 'N' for NO
;
; SDCLINIC("PROVIDER",PROVIDERIEN)="" - ADD
; SDCLINIC("PROVIDER",PROVIDERIEN)="@" - DELETE
; SDCLINIC("PROVIDER",PROVIDERIEN,"DEFAULT")="" - DEFAULT PROVIDER
;
; SDCLINIC("DIAGNOSIS",DIAGNOSIS CODE)="" - ADD
; SDCLINIC("DIAGNOSIS",DIAGNOSIS CODE)="@" - DELETE
; SDCLINIC("DIAGNOSIS",DIAGNOSIS CODE,"DEFAULT")="" - DEFAULT DIAGNOSIS
;
; SDCLINIC("SPECIAL INSTRUCTIONS",NUMBER)="INSTRUCTION ID|@ - FOR DELETION
; 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
;
; SDCLINIC("PRIVILEGED USER",USERIEN)="@" - DELETE
; SDCLINIC("PRIVILEGED USER",USERIEN)="" - ADD
;
EDITCLINIC(RESULTS,SDCONTEXT,SDCLINIC) ;
N ERRORS,SDIEN,CLINRETURN,FILEDATA,VRES,VETSELFCAN
; validate context array
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) S ERRORS("ClinicUpdate",1)="" D BUILDJSON^SDES2JSON(.RESULTS,.ERRORS) Q
D VALCLINIEN^SDES2VAL44(.ERRORS,$G(SDCLINIC("CLINIC IEN")),1)
I $D(ERRORS) S ERRORS("ClinicEdit",1)="" D BUILDJSON^SDES2JSON(.RESULTS,.ERRORS) Q
; validate clinic hash
I $D(SDCLINIC("CLINIC HASH")) D VALCLINICHASH^SDES2VAL44A(.ERRORS,$G(SDCLINIC("CLINIC IEN")),$G(SDCLINIC("CLINIC HASH")))
I $D(ERRORS) S ERRORS("ClinicEdit",1)="" D BUILDJSON^SDES2JSON(.RESULTS,.ERRORS) Q
; validate required fields
I $D(SDCLINIC("ALLOWABLE CONSECUTIVE NO-SHOWS")) D VALALLOWNOSHOW^SDES2VAL44(.ERRORS,$G(SDCLINIC("ALLOWABLE CONSECUTIVE NO-SHOWS")),.FILEDATA)
I $D(SDCLINIC("DIRECT PATIENT SCHEDULING")) D VALDIRPATSCHED^SDES2VAL44(.ERRORS,$G(SDCLINIC("DIRECT PATIENT SCHEDULING")),.FILEDATA)
I $D(SDCLINIC("DISPLAY APPOINTMENTS")) D VALDISPAPPT^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("DIVISION")) D VALDIV^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("E-CHECKIN ALLOWED")) D VALCHECKIN^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("MAX DAYS FUTURE BOOKING")) D VALMAXFUTBOOK^SDES2VAL44(.ERRORS,$G(SDCLINIC("MAX DAYS FUTURE BOOKING")),.FILEDATA)
I $D(SDCLINIC("NAME")) D VALNAME^SDES2VAL44(.ERRORS,$G(SDCLINIC("NAME")),.FILEDATA)
I $D(SDCLINIC("NON-COUNT")) D VALNONCOUNT^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("OVERBOOKS/DAY MAX")) D VALOVBDAYMAX^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("PRIMARY AMIS")) D VALPRIMAMIS^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("PRE-CHECKIN ALLOWED")) D VALPRECHECKIN^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("REQUIRE ACTION PROFILES")) D VALPROFILE^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("SERVICE")) D VALSERVICE^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("MEETS AT FACILITY")) D VALMEETATFACIL^SDES2VAL44(.ERRORS,$G(SDCLINIC("MEETS AT FACILITY")),.FILEDATA)
D VALVETSLFCAN^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(ERRORS) S ERRORS("ClinicUpdate",1)="" D BUILDJSON^SDES2JSON(.RESULTS,.ERRORS) Q
;
; validate non-required fields
I $D(SDCLINIC("PBSPID")) D VALPBSPID^SDES2VAL44(.ERRORS,$G(SDCLINIC("PBSPID")),.FILEDATA)
I $G(SDCLINIC("LENGTH OF APPOINTMENT"))'="" D VALAPPTLENGTH^SDES2VAL44(.ERRORS,$G(SDCLINIC("LENGTH OF APPOINTMENT")),$G(SDCLINIC("CLINIC IEN")),$G(SDCLINIC("DISPLAY INCREMENTS PER HOUR")),.FILEDATA)
I $D(SDCLINIC("ABBREVIATION")) D VALABBR^SDES2VAL44(.ERRORS,$G(SDCLINIC("ABBREVIATION")),.FILEDATA)
I $D(SDCLINIC("ADMIN INPATIENT MEDS")) D VALINPATMED^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("ASK CHECK IN/OUT")) D VALINOUTTIME^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("DEFAULT APPOINTMENT TYPE")) D VALAPPTTYPE^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("PATIENT FRIENDLY NAME")) D VALPATFNAME^SDES2VAL44(.ERRORS,$G(SDCLINIC("PATIENT FRIENDLY NAME")),.FILEDATA)
I $D(SDCLINIC("TELEPHONE")) D VALPHONE^SDES2VAL44(.ERRORS,$G(SDCLINIC("TELEPHONE")),.FILEDATA)
I $D(SDCLINIC("TELEPHONE EXTENSION")) D VALPHONEEXT^SDES2VAL44(.ERRORS,$G(SDCLINIC("TELEPHONE EXTENSION")),.FILEDATA)
I $D(SDCLINIC("REQUIRE X-RAY")) D VALXRAY^SDES2VAL44(.ERRORS,$G(SDCLINIC("REQUIRE X-RAY")),.FILEDATA)
I $D(SDCLINIC("NO-SHOW LETTER")) D VALNOSHOWLET^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("PRE-APPOINTMENT LETTER")) D VALPREAPTLET^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("CLINIC CANCELLATION LETTER")) D VALCANLET^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("APPOINTMENT CANCELLATION LETTER")) D VALAPTCANLET^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("DEFAULT TO PC PRACTITIONER")) D VALDEFAULTTOPRAC^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("WORKLOAD VALIDATION")) D VALWORKLOAD^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("PROHIBIT ACCESS TO CLINIC")) D VALNOACCESS^SDES2VAL44(.ERRORS,$G(SDCLINIC("PROHIBIT ACCESS TO CLINIC")),.FILEDATA)
I $D(SDCLINIC("PHYSICAL LOCATION")) D VALLOCATION^SDES2VAL44(.ERRORS,$G(SDCLINIC("PHYSICAL LOCATION")),.FILEDATA)
I $D(SDCLINIC("PRINCIPAL CLINIC")) D VALPRINCLINIC^SDES2VAL44(.ERRORS,$G(SDCLINIC("PRINCIPAL CLINIC")),.FILEDATA)
I $D(SDCLINIC("VARIABLE APPOINTMENT LENGTH")) D VALVARAPTLENGTH^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
I $D(SDCLINIC("INCLUDE ON FILE ROOM LISTS")) D VALINCLUDEFROOM^SDES2VAL44(.ERRORS,$G(SDCLINIC("INCLUDE ON FILE ROOM LISTS")),.FILEDATA)
I $D(SDCLINIC("SCHEDULE ON HOLIDAYS")) D VALSCHEDHOLIDAY^SDES2VAL44(.ERRORS,$G(SDCLINIC("SCHEDULE ON HOLIDAYS")),.FILEDATA)
; Credit AMIS
I $D(SDCLINIC("CREDIT AMIS")) D VALCREDITAMIS^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
; Conditional amis check
I $D(SDCLINIC("PRIMARY AMIS")),$D(SDCLINIC("CREDIT AMIS")) D CONDAMISCHECK^SDES2VAL44(.ERRORS,$G(SDCLINIC("PRIMARY AMIS")),$G(SDCLINIC("CREDIT AMIS")))
;
S SDIEN=$G(SDCLINIC("CLINIC IEN"))
; validate subfile fields
I $D(SDCLINIC("DIAGNOSIS")) D VALDIAG^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA,SDIEN)
I $D(SDCLINIC("PROVIDER")) D VALPROVIDERS^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA,SDIEN)
I $D(SDCLINIC("PRIVILEGED USER")),($G(SDCLINIC("PROHIBIT ACCESS TO CLINIC"))="Y"!($$GET1^DIQ(44,SDIEN,2500,"I")="Y")) D
.D VALPRIVUSERS^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA,SDIEN)
I $D(SDCLINIC("SPECIAL INSTRUCTIONS")) D VALSPECINSTRUCT^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA,SDIEN)
I $D(ERRORS) D Q
.S ERRORS("ClinicEdit",1)="" D BUILDJSON^SDES2JSON(.RESULTS,.ERRORS) Q
;
D FILECLINDATA(.ERRORS,.FILEDATA,SDIEN)
; always re-hash clinic, in case some fields were filed correctly, even if there were errors.
D ADDHASH2CLIN^SDES2CLINUT(SDIEN)
I $D(ERRORS) D Q
.S ERRORS("ClinicEdit",1)=""
.D BUILDJSON^SDES2JSON(.RESULTS,.ERRORS) Q
;
S CLINRETURN("ClinicEdit","ID")=SDIEN D BUILDJSON^SDES2JSON(.RESULTS,.CLINRETURN)
Q
FILECLINDATA(ERRORS,FILEDATA,SDIEN) ;
N SDIENS,CLINMSG,MESSINC,FDA
Q:'SDIEN
S SDIENS=SDIEN_","
; required fields
I '$D(FILEDATA) D ERRLOG^SDES2JSON(.ERRORS,506) Q
I $D(FILEDATA("NAME")) S FDA(44,SDIENS,.01)=FILEDATA("NAME")
I $D(FILEDATA("DIRECT PATIENT SCHEDULING")) S FDA(44,SDIENS,61)=FILEDATA("DIRECT PATIENT SCHEDULING")
I $D(FILEDATA("DISPLAY APPOINTMENTS")) S FDA(44,SDIENS,62)=FILEDATA("DISPLAY APPOINTMENTS")
I $D(FILEDATA("SERVICE")) S FDA(44,SDIENS,9)=FILEDATA("SERVICE")
I $D(FILEDATA("NON-COUNT")) S FDA(44,SDIENS,2502)=FILEDATA("NON-COUNT")
I $D(FILEDATA("DIVISION")) S FDA(44,SDIENS,3.5)=FILEDATA("DIVISION")
I $D(FILEDATA("PRIMARY AMIS")) S FDA(44,SDIENS,8)=FILEDATA("PRIMARY AMIS")
I $D(FILEDATA("REQUIRE ACTION PROFILES")) S FDA(44,SDIENS,2000.5)=FILEDATA("REQUIRE ACTION PROFILES")
I $D(FILEDATA("ALLOWABLE CONSECUTIVE NO-SHOWS")) S FDA(44,SDIENS,2001)=FILEDATA("ALLOWABLE CONSECUTIVE NO-SHOWS")
I $D(FILEDATA("MAX DAYS FUTURE BOOKING")) S FDA(44,SDIENS,2002)=FILEDATA("MAX DAYS FUTURE BOOKING")
I $D(FILEDATA("OVERBOOKS/DAY MAX")) S FDA(44,SDIENS,1918)=FILEDATA("OVERBOOKS/DAY MAX")
I $D(FILEDATA("E-CHECKIN ALLOWED")) S FDA(44,SDIENS,20)=FILEDATA("E-CHECKIN ALLOWED")
I $D(FILEDATA("PRE-CHECKIN ALLOWED")) S FDA(44,SDIENS,21)=FILEDATA("PRE-CHECKIN ALLOWED")
; non-required fields
I $G(FILEDATA("PBSPID"))'="" S FDA(44,SDIENS,200)=$G(FILEDATA("PBSPID"))
I $G(FILEDATA("LENGTH OF APPOINTMENT"))'="" S FDA(44,SDIENS,1912)=$G(FILEDATA("LENGTH OF APPOINTMENT"))
I $G(FILEDATA("DISPLAY INCREMENTS PER HOUR"))'="" S FDA(44,SDIENS,1917)=$G(FILEDATA("DISPLAY INCREMENTS PER HOUR"))
I $D(FILEDATA("ABBREVIATION")) S FDA(44,SDIENS,1)=FILEDATA("ABBREVIATION")
I $D(FILEDATA("PATIENT FRIENDLY NAME")) S FDA(44,SDIENS,60)=FILEDATA("PATIENT FRIENDLY NAME")
I $D(FILEDATA("DEFAULT APPOINTMENT TYPE")) S FDA(44,SDIENS,2507)=FILEDATA("DEFAULT APPOINTMENT TYPE")
I $D(FILEDATA("ADMIN INPATIENT MEDS")) S FDA(44,SDIENS,2802)=FILEDATA("ADMIN INPATIENT MEDS")
I $D(FILEDATA("MEETS AT FACILITY")) S FDA(44,SDIENS,2504)=FILEDATA("MEETS AT FACILITY")
I $D(FILEDATA("TELEPHONE")) S FDA(44,SDIENS,99)=FILEDATA("TELEPHONE")
I $D(FILEDATA("TELEPHONE EXTENSION")) S FDA(44,SDIENS,99.1)=FILEDATA("TELEPHONE EXTENSION")
I $D(FILEDATA("REQUIRE X-RAY")) S FDA(44,SDIENS,2000)=FILEDATA("REQUIRE X-RAY")
I $D(FILEDATA("NO-SHOW LETTER")) S FDA(44,SDIENS,2508)=FILEDATA("NO-SHOW LETTER")
I $D(FILEDATA("PRE-APPOINTMENT LETTER")) S FDA(44,SDIENS,2509)=FILEDATA("PRE-APPOINTMENT LETTER")
I $D(FILEDATA("CLINIC CANCELLATION LETTER")) S FDA(44,SDIENS,2510)=FILEDATA("CLINIC CANCELLATION LETTER")
I $D(FILEDATA("APPOINTMENT CANCELLATION LETTER")) S FDA(44,SDIENS,2511)=FILEDATA("APPOINTMENT CANCELLATION LETTER")
I $D(FILEDATA("ASK CHECK IN/OUT")) S FDA(44,SDIENS,24)=FILEDATA("ASK CHECK IN/OUT")
I $D(FILEDATA("DEFAULT TO PC PRACTITIONER")) S FDA(44,SDIENS,2801)=FILEDATA("DEFAULT TO PC PRACTITIONER")
I $D(FILEDATA("WORKLOAD VALIDATION")) S FDA(44,SDIENS,30)=FILEDATA("WORKLOAD VALIDATION")
I $D(FILEDATA("PROHIBIT ACCESS TO CLINIC")) S FDA(44,SDIENS,2500)=FILEDATA("PROHIBIT ACCESS TO CLINIC")
I $D(FILEDATA("PHYSICAL LOCATION")) S FDA(44,SDIENS,10)=FILEDATA("PHYSICAL LOCATION")
I $D(FILEDATA("PRINCIPAL CLINIC")) S FDA(44,SDIENS,1916)=FILEDATA("PRINCIPAL CLINIC")
I $D(FILEDATA("VARIABLE APPOINTMENT LENGTH")) S FDA(44,SDIENS,1913)=FILEDATA("VARIABLE APPOINTMENT LENGTH")
I $D(FILEDATA("CREDIT AMIS")) S FDA(44,SDIENS,2503)=FILEDATA("CREDIT AMIS")
I $D(FILEDATA("INCLUDE ON FILE ROOM LISTS")) S FDA(44,SDIENS,2502.5)=$G(FILEDATA("INCLUDE ON FILE ROOM LISTS"))
I $D(FILEDATA("SCHEDULE ON HOLIDAYS")) S FDA(44,SDIENS,1918.5)=$G(FILEDATA("SCHEDULE ON HOLIDAYS"))
I $D(FILEDATA("VETERAN SELF-CANCEL")) S FDA(44,SDIENS,63)=$G(FILEDATA("VETERAN SELF-CANCEL"))
I $D(FDA) D
.D FILE^DIE(,"FDA","CLINMSG") K FDA
.I $D(CLINMSG) D
..F MESSINC=1:1:$G(CLINMSG("DIERR")) D ERRLOG^SDES2JSON(.ERRORS,52,$G(CLINMSG("DIERR",MESSINC,"TEXT",1)))
; Save subfile entries
I $D(FILEDATA("PROVIDER")) D SAVEPROVIDERS^SDES2CLINUT(.ERRORS,.FILEDATA,SDIEN)
I $D(FILEDATA("DIAGNOSIS")) D SAVEDIAG^SDES2CLINUT(.ERRORS,.FILEDATA,SDIEN)
I $D(FILEDATA("SPECIAL INSTRUCTIONS")) D SAVEINSTRUCT^SDES2CLINUT(.ERRORS,.FILEDATA,SDIEN)
I $D(FILEDATA("PRIVILEGED USER")) D SAVEPRIVUSERS^SDES2CLINUT(.ERRORS,.FILEDATA,SDIEN)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2EDITCLIN 17815 printed Dec 13, 2024@02:53:46 Page 2
SDES2EDITCLIN ;ALB/BWF,MGD/BLB,BWF,TJB - SDES2 EDIT CLINIC ;JAN 02, 2024
+1 ;;5.3;Scheduling;**853,857,864,866,871,885,890,893**;Aug 13, 1993;Build 6
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ; Reference to ^DG(40.8 is supported by IA #2295
+6 ; Reference to ^DG(40.8 is supported by IA #7024
+7 ;
+8 ; SDNAME - [TEXT, REQ] Clinic Name (REQUIRED)
+9 ; SDABR - [TEXT] ABBREVIATION
+10 ; SDPATNAME - [TEXT] PATIENT FRIENDLY NAME
+11 ; SDMEETATFAC - [Y/N] CLINIC MEETS AT THIS FACILITY? (Default = Y)
+12 ; SDPATSCHED - [Y/N, REQ] ALLOW DIRECT PATIENT SCHEDULING? (REQUIRED)
+13 ; SDDISPAPPT - [Y/N, REQ] DISPLAY CLIN APPT TO PATIENTS? (REQUIRED)
+14 ; SDSERVICE - [Set of codes, REQ] SERVICE (REQUIRED)
+15 ; SDNONCOUNT - [Y/N, REQ] NON-COUNT CLINIC? (Y OR N) (REQUIRED)
+16 ; SDDIVISION - [File 40.8] DIVISION (REQUIRED)
+17 ; SDAPPTTYP - [File 409.1] DEFAULT APPOINTMENT TYPE
+18 ; SDINPATMED - [Y/N] ADMINISTER INPATIENT MEDS?
+19 ; SDPHONE - [TEXT] TELEPHONE
+20 ; SDREQXRAY - [Y/N] REQUIRE X-RAY FILMS?
+21 ; SDREQPROFILE - [Y/N] REQUIRE ACTION PROFILES? (REQUIRED)
+22 ; SDNOSHOWLET - [File 407.5] NO SHOW LETTER
+23 ; SDPREAPTLET - [File 407.5] PRE-APPOINTMENT LETTER
+24 ; SDCANLET - [File 407.5] CLINIC CANCELLATION LETTER
+25 ; SDAPTCANLET - [File 407.5] APPT. CANCELLATION LETTER
+26 ; SDINOUTTIME - [Y/N] ASK FOR CHECK IN/OUT TIME
+27 ; SDPROVIDER - [File 200] PROVIDER
+28 ; SDPRACTIONER - [Y/N] DEFAULT TO PC PRACTITIONER?
+29 ; SDDIAG - [file 80] DIAGNOSIS
+30 ; SDWORKLOAD - [Y/N] WORKLOAD VALIDATION AT CHK OUT
+31 ; SDALLOWNOSHW - [NUM, REQ] ALLOWABLE CONSECUTIVE NO-SHOWS (REQUIRED)
+32 ; SDMAXFUTBOOK - [NUM, REQ] MAX # DAYS FOR FUTURE BOOKING (REQUIRED)
+33 ; SDNOACCESS - [Y/N] PROHIBIT ACCESS TO CLINIC?
+34 ; SDLOCATION - [TEXT] PHYSICAL LOCATION
+35 ; SDPRINCLINIC - [File 44] PRINCIPAL Clinic
+36 ; SDOVBDAYMAX - [NUM, REQ] OVERBOOKS/DAY MAXIMUM (REQUIRED)
+37 ; SDSPECINSTRU - [TEXT] SPECIAL INSTRUCTIONS
+38 ; SDECHECKIN - [Y/N] E-CHECKIN ALLOWED (REQUIRED)
+39 ; SDPRECHECKIN - [Y/N] PRE-CHECKIN ALLOWED (REQUIRED)
+40 ; SDVARAPTLNG - [TEXT] VARIABLE APP'NTMENT LENGTH
+41 ; PRIAMIS - [NUM, OPT] AMIS Primary Stop Code
+42 ; CREDITAMIS - [NUM, OPT] AMIS Credit Stop Code
+43 ; CLINIC HASH - [TEXT] SHA-1 Hash value that the calling app has stored
+44 ; LENGTH OF APPOINTMENT - APPOINTMENT LENGTH
+45 ; VETERAN SELF-CANCEL - "Y" for Yes, "N" for No
+46 ;
+47 ; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
+48 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
+49 ; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
+50 ; SDCONTEXT("PATIENT DFN") = The DFN/IEN of the target patient from the calling application.
+51 ; SDCONTEXT("PATIENT ICN") = The ICN of the target patient from the calling application.
+52 ;
+53 ;
+54 ; To delete a single field, set that array element to "@" or ""
+55 ; SDCLINIC("FIELD NAME")="@" or SDCLINIC("FIELD NAME")=""
+56 ; SDCLINIC("CLINIC IEN")=CLINIC IEN IEN of the clinic in file 44 - Hospital location
+57 ; SDCLINIC("NAME")=CLINIC NAME FREE TEXT 2-30 characters (Required)
+58 ; SDCLINIC("ABBREVIATION")=ABBREVIATION FREE TEXT 1-7 characters
+59 ; SDCLINIC("PATIENT FRIENDLY NAME") FREE TEXT 1-80 characters
+60 ; SDCLINIC("MEETS AT FACILITY") Y/N for (YES/NO) (Required)
+61 ; SDCLINIC("DIRECT PATIENT SCHEDULING") Y/N for (YES/NO)
+62 ; SDCLINIC("DISPLAY APPOINTMENTS") Y/N for (YES/NO)
+63 ; SDCLINIC("SERVICE") SET OF CODES (M/S/P/R/N/0)
+64 ; SDCLINIC("NON-COUNT") Y/N for (YES/NO)
+65 ; SDCLINIC("DIVISION") POINTER TO MEDICAL CENTER DIVISION FILE (#40.8)
+66 ; SDCLINIC("DEFAULT APPOINTMENT TYPE") POINTER TO APPOINTMENT TYPE FILE (#409.1)
+67 ; SDCLINIC("ADMIN INPATIENT MEDS") 'Y' for 'Yes', blank/NULL for 'No'
+68 ; SDCLINIC("TELEPHONE") FREE TEXT 3-13 characters
+69 ; SDCLINIC("TELEPHONE EXTENSION") FREE TEXT 1-26 characters
+70 ; SDCLINIC("REQUIRE X-RAY") 'Y' for 'Yes', null for No
+71 ; SDCLINIC("REQUIRE ACTION PROFILES") Y/N for (YES/NO)
+72 ; SDCLINIC("NO-SHOW LETTER") LETTER NAME OR IEN POINTER TO LETTER FILE (#407.5)
+73 ; SDCLINIC("PRE-APPOINTMENT LETTER") LETTER NAME OR IEN POINTER TO LETTER FILE (#407.5)
+74 ; SDCLINIC("CLINIC CANCELLATION LETTER") LETTER NAME OR IEN POINTER TO LETTER FILE (#407.5)
+75 ; SDCLINIC("APPOINTMENT CANCELLATION LETTER") LETTER NAME OR IEN POINTER TO LETTER FILE (#407.5)
+76 ; SDCLINIC("ASK CHECK IN/OUT") Y/N for (YES/NO)
+77 ; SDCLINIC("DEFAULT TO PC PRACTITIONER") Y/N for (YES/NO)
+78 ; SDCLINIC("WORKLOAD VALIDATION") Y/N for (YES/NO)
+79 ; SDCLINIC("ALLOWABLE CONSECUTIVE NO-SHOWS") NUMBER 0-999
+80 ; SDCLINIC("MAX DAYS FUTURE BOOKING") NUMBER 11-999
+81 ; SDCLINIC("PROHIBIT ACCESS TO CLINIC") 'Y' for 'Yes'
+82 ; SDCLINIC("PHYSICAL LOCATION") FREE TEXT (1-25)
+83 ; SDCLINIC("PRINCIPAL CLINIC") POINTER to the Hospital location file (#44)
+84 ; SDCLINIC("OVERBOOKS/DAY MAX") NUMBER 0-9999
+85 ; SDCLINIC("E-CHECKIN ALLOWED") Y/N for (YES/NO)
+86 ; SDCLINIC("PRE-CHECKIN ALLOWED") Y/N for (YES/NO)
+87 ; SDCLINIC("VARIABLE APPOINTMENT LENGTH") 'Y' - for Variable appointment length, Null for not variable
+88 ; SDCLINIC("PRIMARY AMIS") NUMERIC AMIS CODE (1-999)
+89 ; SDCLINIC("CREDIT AMIS") NUMERIC AMIS CODE (1-999)
+90 ; SDCLINIC("INCLUDE ON FILE ROOM LISTS") Y/N for (YES/NO)
+91 ; SDCLINIC("SCHEDULE ON HOLIDAYS") 'Y' for 'Yes'
+92 ; SDCLINIC("LENGTH OF APPOINTMENT") LENGTH OF APPOINTMENT
+93 ; SDCLINIC("DISPLAY INCREMENTS PER HOUR") DISPLAY INCREMENTS PER HOUR
+94 ; SDCLINIC("CLINIC HASH") [TEXT] SHA-1 Hash value that the calling app has stored
+95 ; SDCLINIC("VETERAN SELF-CANCEL") 'Y' for 'YES', 'N' for NO
+96 ;
+97 ; SDCLINIC("PROVIDER",PROVIDERIEN)="" - ADD
+98 ; SDCLINIC("PROVIDER",PROVIDERIEN)="@" - DELETE
+99 ; SDCLINIC("PROVIDER",PROVIDERIEN,"DEFAULT")="" - DEFAULT PROVIDER
+100 ;
+101 ; SDCLINIC("DIAGNOSIS",DIAGNOSIS CODE)="" - ADD
+102 ; SDCLINIC("DIAGNOSIS",DIAGNOSIS CODE)="@" - DELETE
+103 ; SDCLINIC("DIAGNOSIS",DIAGNOSIS CODE,"DEFAULT")="" - DEFAULT DIAGNOSIS
+104 ;
+105 ; SDCLINIC("SPECIAL INSTRUCTIONS",NUMBER)="INSTRUCTION ID|@ - FOR DELETION
+106 ; SDCLINIC("SPECIAL INSTRUCTIONS",NUMBER)=" (null value) |SPECIAL INSTRUCTION TEXT UP TO 80 CHARACTERS" - FOR ADDITION
+107 ; SDCLINIC("SPECIAL INSTRUCTIONS",NUMBER)="INSTRUCTION ID|SPECIAL INSTRUCTION TEXT UP TO 80 CHARACTERS" - FOR EDIT
+108 ;
+109 ; SDCLINIC("PRIVILEGED USER",USERIEN)="@" - DELETE
+110 ; SDCLINIC("PRIVILEGED USER",USERIEN)="" - ADD
+111 ;
EDITCLINIC(RESULTS,SDCONTEXT,SDCLINIC) ;
+1 NEW ERRORS,SDIEN,CLINRETURN,FILEDATA,VRES,VETSELFCAN
+2 ; validate context array
+3 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+4 IF $DATA(ERRORS)
SET ERRORS("ClinicUpdate",1)=""
DO BUILDJSON^SDES2JSON(.RESULTS,.ERRORS)
QUIT
+5 DO VALCLINIEN^SDES2VAL44(.ERRORS,$GET(SDCLINIC("CLINIC IEN")),1)
+6 IF $DATA(ERRORS)
SET ERRORS("ClinicEdit",1)=""
DO BUILDJSON^SDES2JSON(.RESULTS,.ERRORS)
QUIT
+7 ; validate clinic hash
+8 IF $DATA(SDCLINIC("CLINIC HASH"))
DO VALCLINICHASH^SDES2VAL44A(.ERRORS,$GET(SDCLINIC("CLINIC IEN")),$GET(SDCLINIC("CLINIC HASH")))
+9 IF $DATA(ERRORS)
SET ERRORS("ClinicEdit",1)=""
DO BUILDJSON^SDES2JSON(.RESULTS,.ERRORS)
QUIT
+10 ; validate required fields
+11 IF $DATA(SDCLINIC("ALLOWABLE CONSECUTIVE NO-SHOWS"))
DO VALALLOWNOSHOW^SDES2VAL44(.ERRORS,$GET(SDCLINIC("ALLOWABLE CONSECUTIVE NO-SHOWS")),.FILEDATA)
+12 IF $DATA(SDCLINIC("DIRECT PATIENT SCHEDULING"))
DO VALDIRPATSCHED^SDES2VAL44(.ERRORS,$GET(SDCLINIC("DIRECT PATIENT SCHEDULING")),.FILEDATA)
+13 IF $DATA(SDCLINIC("DISPLAY APPOINTMENTS"))
DO VALDISPAPPT^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+14 IF $DATA(SDCLINIC("DIVISION"))
DO VALDIV^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+15 IF $DATA(SDCLINIC("E-CHECKIN ALLOWED"))
DO VALCHECKIN^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+16 IF $DATA(SDCLINIC("MAX DAYS FUTURE BOOKING"))
DO VALMAXFUTBOOK^SDES2VAL44(.ERRORS,$GET(SDCLINIC("MAX DAYS FUTURE BOOKING")),.FILEDATA)
+17 IF $DATA(SDCLINIC("NAME"))
DO VALNAME^SDES2VAL44(.ERRORS,$GET(SDCLINIC("NAME")),.FILEDATA)
+18 IF $DATA(SDCLINIC("NON-COUNT"))
DO VALNONCOUNT^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+19 IF $DATA(SDCLINIC("OVERBOOKS/DAY MAX"))
DO VALOVBDAYMAX^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+20 IF $DATA(SDCLINIC("PRIMARY AMIS"))
DO VALPRIMAMIS^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+21 IF $DATA(SDCLINIC("PRE-CHECKIN ALLOWED"))
DO VALPRECHECKIN^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+22 IF $DATA(SDCLINIC("REQUIRE ACTION PROFILES"))
DO VALPROFILE^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+23 IF $DATA(SDCLINIC("SERVICE"))
DO VALSERVICE^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+24 IF $DATA(SDCLINIC("MEETS AT FACILITY"))
DO VALMEETATFACIL^SDES2VAL44(.ERRORS,$GET(SDCLINIC("MEETS AT FACILITY")),.FILEDATA)
+25 DO VALVETSLFCAN^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA)
+26 IF $DATA(ERRORS)
SET ERRORS("ClinicUpdate",1)=""
DO BUILDJSON^SDES2JSON(.RESULTS,.ERRORS)
QUIT
+27 ;
+28 ; validate non-required fields
+29 IF $DATA(SDCLINIC("PBSPID"))
DO VALPBSPID^SDES2VAL44(.ERRORS,$GET(SDCLINIC("PBSPID")),.FILEDATA)
+30 IF $GET(SDCLINIC("LENGTH OF APPOINTMENT"))'=""
DO VALAPPTLENGTH^SDES2VAL44(.ERRORS,$GET(SDCLINIC("LENGTH OF APPOINTMENT")),$GET(SDCLINIC("CLINIC IEN")),$GET(SDCLINIC("DISPLAY INCREMENTS PER HOUR")),.FILEDATA)
+31 IF $DATA(SDCLINIC("ABBREVIATION"))
DO VALABBR^SDES2VAL44(.ERRORS,$GET(SDCLINIC("ABBREVIATION")),.FILEDATA)
+32 IF $DATA(SDCLINIC("ADMIN INPATIENT MEDS"))
DO VALINPATMED^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+33 IF $DATA(SDCLINIC("ASK CHECK IN/OUT"))
DO VALINOUTTIME^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+34 IF $DATA(SDCLINIC("DEFAULT APPOINTMENT TYPE"))
DO VALAPPTTYPE^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+35 IF $DATA(SDCLINIC("PATIENT FRIENDLY NAME"))
DO VALPATFNAME^SDES2VAL44(.ERRORS,$GET(SDCLINIC("PATIENT FRIENDLY NAME")),.FILEDATA)
+36 IF $DATA(SDCLINIC("TELEPHONE"))
DO VALPHONE^SDES2VAL44(.ERRORS,$GET(SDCLINIC("TELEPHONE")),.FILEDATA)
+37 IF $DATA(SDCLINIC("TELEPHONE EXTENSION"))
DO VALPHONEEXT^SDES2VAL44(.ERRORS,$GET(SDCLINIC("TELEPHONE EXTENSION")),.FILEDATA)
+38 IF $DATA(SDCLINIC("REQUIRE X-RAY"))
DO VALXRAY^SDES2VAL44(.ERRORS,$GET(SDCLINIC("REQUIRE X-RAY")),.FILEDATA)
+39 IF $DATA(SDCLINIC("NO-SHOW LETTER"))
DO VALNOSHOWLET^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+40 IF $DATA(SDCLINIC("PRE-APPOINTMENT LETTER"))
DO VALPREAPTLET^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+41 IF $DATA(SDCLINIC("CLINIC CANCELLATION LETTER"))
DO VALCANLET^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+42 IF $DATA(SDCLINIC("APPOINTMENT CANCELLATION LETTER"))
DO VALAPTCANLET^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+43 IF $DATA(SDCLINIC("DEFAULT TO PC PRACTITIONER"))
DO VALDEFAULTTOPRAC^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+44 IF $DATA(SDCLINIC("WORKLOAD VALIDATION"))
DO VALWORKLOAD^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+45 IF $DATA(SDCLINIC("PROHIBIT ACCESS TO CLINIC"))
DO VALNOACCESS^SDES2VAL44(.ERRORS,$GET(SDCLINIC("PROHIBIT ACCESS TO CLINIC")),.FILEDATA)
+46 IF $DATA(SDCLINIC("PHYSICAL LOCATION"))
DO VALLOCATION^SDES2VAL44(.ERRORS,$GET(SDCLINIC("PHYSICAL LOCATION")),.FILEDATA)
+47 IF $DATA(SDCLINIC("PRINCIPAL CLINIC"))
DO VALPRINCLINIC^SDES2VAL44(.ERRORS,$GET(SDCLINIC("PRINCIPAL CLINIC")),.FILEDATA)
+48 IF $DATA(SDCLINIC("VARIABLE APPOINTMENT LENGTH"))
DO VALVARAPTLENGTH^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+49 IF $DATA(SDCLINIC("INCLUDE ON FILE ROOM LISTS"))
DO VALINCLUDEFROOM^SDES2VAL44(.ERRORS,$GET(SDCLINIC("INCLUDE ON FILE ROOM LISTS")),.FILEDATA)
+50 IF $DATA(SDCLINIC("SCHEDULE ON HOLIDAYS"))
DO VALSCHEDHOLIDAY^SDES2VAL44(.ERRORS,$GET(SDCLINIC("SCHEDULE ON HOLIDAYS")),.FILEDATA)
+51 ; Credit AMIS
+52 IF $DATA(SDCLINIC("CREDIT AMIS"))
DO VALCREDITAMIS^SDES2VAL44(.ERRORS,.SDCLINIC,.FILEDATA)
+53 ; Conditional amis check
+54 IF $DATA(SDCLINIC("PRIMARY AMIS"))
IF $DATA(SDCLINIC("CREDIT AMIS"))
DO CONDAMISCHECK^SDES2VAL44(.ERRORS,$GET(SDCLINIC("PRIMARY AMIS")),$GET(SDCLINIC("CREDIT AMIS")))
+55 ;
+56 SET SDIEN=$GET(SDCLINIC("CLINIC IEN"))
+57 ; validate subfile fields
+58 IF $DATA(SDCLINIC("DIAGNOSIS"))
DO VALDIAG^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA,SDIEN)
+59 IF $DATA(SDCLINIC("PROVIDER"))
DO VALPROVIDERS^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA,SDIEN)
+60 IF $DATA(SDCLINIC("PRIVILEGED USER"))
IF ($GET(SDCLINIC("PROHIBIT ACCESS TO CLINIC"))="Y"!($$GET1^DIQ(44,SDIEN,2500,"I")="Y"))
Begin DoDot:1
+61 DO VALPRIVUSERS^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA,SDIEN)
End DoDot:1
+62 IF $DATA(SDCLINIC("SPECIAL INSTRUCTIONS"))
DO VALSPECINSTRUCT^SDES2VAL44A(.ERRORS,.SDCLINIC,.FILEDATA,SDIEN)
+63 IF $DATA(ERRORS)
Begin DoDot:1
+64 SET ERRORS("ClinicEdit",1)=""
DO BUILDJSON^SDES2JSON(.RESULTS,.ERRORS)
QUIT
End DoDot:1
QUIT
+65 ;
+66 DO FILECLINDATA(.ERRORS,.FILEDATA,SDIEN)
+67 ; always re-hash clinic, in case some fields were filed correctly, even if there were errors.
+68 DO ADDHASH2CLIN^SDES2CLINUT(SDIEN)
+69 IF $DATA(ERRORS)
Begin DoDot:1
+70 SET ERRORS("ClinicEdit",1)=""
+71 DO BUILDJSON^SDES2JSON(.RESULTS,.ERRORS)
QUIT
End DoDot:1
QUIT
+72 ;
+73 SET CLINRETURN("ClinicEdit","ID")=SDIEN
DO BUILDJSON^SDES2JSON(.RESULTS,.CLINRETURN)
+74 QUIT
FILECLINDATA(ERRORS,FILEDATA,SDIEN) ;
+1 NEW SDIENS,CLINMSG,MESSINC,FDA
+2 if 'SDIEN
QUIT
+3 SET SDIENS=SDIEN_","
+4 ; required fields
+5 IF '$DATA(FILEDATA)
DO ERRLOG^SDES2JSON(.ERRORS,506)
QUIT
+6 IF $DATA(FILEDATA("NAME"))
SET FDA(44,SDIENS,.01)=FILEDATA("NAME")
+7 IF $DATA(FILEDATA("DIRECT PATIENT SCHEDULING"))
SET FDA(44,SDIENS,61)=FILEDATA("DIRECT PATIENT SCHEDULING")
+8 IF $DATA(FILEDATA("DISPLAY APPOINTMENTS"))
SET FDA(44,SDIENS,62)=FILEDATA("DISPLAY APPOINTMENTS")
+9 IF $DATA(FILEDATA("SERVICE"))
SET FDA(44,SDIENS,9)=FILEDATA("SERVICE")
+10 IF $DATA(FILEDATA("NON-COUNT"))
SET FDA(44,SDIENS,2502)=FILEDATA("NON-COUNT")
+11 IF $DATA(FILEDATA("DIVISION"))
SET FDA(44,SDIENS,3.5)=FILEDATA("DIVISION")
+12 IF $DATA(FILEDATA("PRIMARY AMIS"))
SET FDA(44,SDIENS,8)=FILEDATA("PRIMARY AMIS")
+13 IF $DATA(FILEDATA("REQUIRE ACTION PROFILES"))
SET FDA(44,SDIENS,2000.5)=FILEDATA("REQUIRE ACTION PROFILES")
+14 IF $DATA(FILEDATA("ALLOWABLE CONSECUTIVE NO-SHOWS"))
SET FDA(44,SDIENS,2001)=FILEDATA("ALLOWABLE CONSECUTIVE NO-SHOWS")
+15 IF $DATA(FILEDATA("MAX DAYS FUTURE BOOKING"))
SET FDA(44,SDIENS,2002)=FILEDATA("MAX DAYS FUTURE BOOKING")
+16 IF $DATA(FILEDATA("OVERBOOKS/DAY MAX"))
SET FDA(44,SDIENS,1918)=FILEDATA("OVERBOOKS/DAY MAX")
+17 IF $DATA(FILEDATA("E-CHECKIN ALLOWED"))
SET FDA(44,SDIENS,20)=FILEDATA("E-CHECKIN ALLOWED")
+18 IF $DATA(FILEDATA("PRE-CHECKIN ALLOWED"))
SET FDA(44,SDIENS,21)=FILEDATA("PRE-CHECKIN ALLOWED")
+19 ; non-required fields
+20 IF $GET(FILEDATA("PBSPID"))'=""
SET FDA(44,SDIENS,200)=$GET(FILEDATA("PBSPID"))
+21 IF $GET(FILEDATA("LENGTH OF APPOINTMENT"))'=""
SET FDA(44,SDIENS,1912)=$GET(FILEDATA("LENGTH OF APPOINTMENT"))
+22 IF $GET(FILEDATA("DISPLAY INCREMENTS PER HOUR"))'=""
SET FDA(44,SDIENS,1917)=$GET(FILEDATA("DISPLAY INCREMENTS PER HOUR"))
+23 IF $DATA(FILEDATA("ABBREVIATION"))
SET FDA(44,SDIENS,1)=FILEDATA("ABBREVIATION")
+24 IF $DATA(FILEDATA("PATIENT FRIENDLY NAME"))
SET FDA(44,SDIENS,60)=FILEDATA("PATIENT FRIENDLY NAME")
+25 IF $DATA(FILEDATA("DEFAULT APPOINTMENT TYPE"))
SET FDA(44,SDIENS,2507)=FILEDATA("DEFAULT APPOINTMENT TYPE")
+26 IF $DATA(FILEDATA("ADMIN INPATIENT MEDS"))
SET FDA(44,SDIENS,2802)=FILEDATA("ADMIN INPATIENT MEDS")
+27 IF $DATA(FILEDATA("MEETS AT FACILITY"))
SET FDA(44,SDIENS,2504)=FILEDATA("MEETS AT FACILITY")
+28 IF $DATA(FILEDATA("TELEPHONE"))
SET FDA(44,SDIENS,99)=FILEDATA("TELEPHONE")
+29 IF $DATA(FILEDATA("TELEPHONE EXTENSION"))
SET FDA(44,SDIENS,99.1)=FILEDATA("TELEPHONE EXTENSION")
+30 IF $DATA(FILEDATA("REQUIRE X-RAY"))
SET FDA(44,SDIENS,2000)=FILEDATA("REQUIRE X-RAY")
+31 IF $DATA(FILEDATA("NO-SHOW LETTER"))
SET FDA(44,SDIENS,2508)=FILEDATA("NO-SHOW LETTER")
+32 IF $DATA(FILEDATA("PRE-APPOINTMENT LETTER"))
SET FDA(44,SDIENS,2509)=FILEDATA("PRE-APPOINTMENT LETTER")
+33 IF $DATA(FILEDATA("CLINIC CANCELLATION LETTER"))
SET FDA(44,SDIENS,2510)=FILEDATA("CLINIC CANCELLATION LETTER")
+34 IF $DATA(FILEDATA("APPOINTMENT CANCELLATION LETTER"))
SET FDA(44,SDIENS,2511)=FILEDATA("APPOINTMENT CANCELLATION LETTER")
+35 IF $DATA(FILEDATA("ASK CHECK IN/OUT"))
SET FDA(44,SDIENS,24)=FILEDATA("ASK CHECK IN/OUT")
+36 IF $DATA(FILEDATA("DEFAULT TO PC PRACTITIONER"))
SET FDA(44,SDIENS,2801)=FILEDATA("DEFAULT TO PC PRACTITIONER")
+37 IF $DATA(FILEDATA("WORKLOAD VALIDATION"))
SET FDA(44,SDIENS,30)=FILEDATA("WORKLOAD VALIDATION")
+38 IF $DATA(FILEDATA("PROHIBIT ACCESS TO CLINIC"))
SET FDA(44,SDIENS,2500)=FILEDATA("PROHIBIT ACCESS TO CLINIC")
+39 IF $DATA(FILEDATA("PHYSICAL LOCATION"))
SET FDA(44,SDIENS,10)=FILEDATA("PHYSICAL LOCATION")
+40 IF $DATA(FILEDATA("PRINCIPAL CLINIC"))
SET FDA(44,SDIENS,1916)=FILEDATA("PRINCIPAL CLINIC")
+41 IF $DATA(FILEDATA("VARIABLE APPOINTMENT LENGTH"))
SET FDA(44,SDIENS,1913)=FILEDATA("VARIABLE APPOINTMENT LENGTH")
+42 IF $DATA(FILEDATA("CREDIT AMIS"))
SET FDA(44,SDIENS,2503)=FILEDATA("CREDIT AMIS")
+43 IF $DATA(FILEDATA("INCLUDE ON FILE ROOM LISTS"))
SET FDA(44,SDIENS,2502.5)=$GET(FILEDATA("INCLUDE ON FILE ROOM LISTS"))
+44 IF $DATA(FILEDATA("SCHEDULE ON HOLIDAYS"))
SET FDA(44,SDIENS,1918.5)=$GET(FILEDATA("SCHEDULE ON HOLIDAYS"))
+45 IF $DATA(FILEDATA("VETERAN SELF-CANCEL"))
SET FDA(44,SDIENS,63)=$GET(FILEDATA("VETERAN SELF-CANCEL"))
+46 IF $DATA(FDA)
Begin DoDot:1
+47 DO FILE^DIE(,"FDA","CLINMSG")
KILL FDA
+48 IF $DATA(CLINMSG)
Begin DoDot:2
+49 FOR MESSINC=1:1:$GET(CLINMSG("DIERR"))
DO ERRLOG^SDES2JSON(.ERRORS,52,$GET(CLINMSG("DIERR",MESSINC,"TEXT",1)))
End DoDot:2
End DoDot:1
+50 ; Save subfile entries
+51 IF $DATA(FILEDATA("PROVIDER"))
DO SAVEPROVIDERS^SDES2CLINUT(.ERRORS,.FILEDATA,SDIEN)
+52 IF $DATA(FILEDATA("DIAGNOSIS"))
DO SAVEDIAG^SDES2CLINUT(.ERRORS,.FILEDATA,SDIEN)
+53 IF $DATA(FILEDATA("SPECIAL INSTRUCTIONS"))
DO SAVEINSTRUCT^SDES2CLINUT(.ERRORS,.FILEDATA,SDIEN)
+54 IF $DATA(FILEDATA("PRIVILEGED USER"))
DO SAVEPRIVUSERS^SDES2CLINUT(.ERRORS,.FILEDATA,SDIEN)
+55 QUIT