SDESHASHCLIN ;ALB/LAB,MGD,BWF - VISTA SCHEDULING RPCS HASH CLINIC ;Nov 14, 2022
;;5.3;Scheduling;**823,824,828,871**;Aug 13, 1993;Build 13
;;Per VHA Directive 6402, this routine should not be modified
Q
;
HASHALL ;hash all clinics this will be a jobbed option: SDES HASH ALL CLINICS
NEW CLINIC,CNT,LISTOFHASH,FDA,FDAERR,TMPCNT
S (CLIN,CNT)=0
F S CLIN=$O(^SC(CLIN)) Q:(+CLIN=0) D
. Q:$E($$GET1^DIQ(44,CLIN,.01,"E"),1,2)="ZZ"
. K X,CLINRET
. S CNT=CNT+1,TMPCNT=0
. D BLDCLNREC(.CLINRET,CLIN,.TMPCNT)
. S FDA(44,CLIN_",",2900)=$$LSHAN^XLFSHAN(160,"XLFMSG",TMPCNT)
. S FDA(44,CLIN_",",2901)=$$NOW^XLFDT
. D FILE^DIE(,"FDA","FDAERR") K FDA
. K ^TMP($J,"XLFMSG")
Q
;
GETALLHASHCLIN(JSONRETURN,ISODATE,SDEAS) ;get all get clinic's hash value
;if date passed in, then will return all clinics that have been hashed since the date/time passed in.
;date is in ISO 8601 format.
NEW HASHREC,SDHASERROR
D VALIDATEDATE(.SDHASERROR,.ISODATE)
D VALIDATEEAS(.SDHASERROR,.SDEAS)
I '$D(SDHASERROR) D
. D BUILDRETURN(.HASHREC,ISODATE)
I $D(SDHASERROR) D
. M HASHREC=SDHASERROR
D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.HASHREC)
Q
;
VALIDATEDATE(ERRORS,ISODATE) ;validate incoming date, convert to FileMan Format
S ISODATE=$G(ISODATE)
I ISODATE'="" S ISODATE=$$ISOTFM^SDAMUTDT(ISODATE)
I ISODATE=-1 D ERRLOG^SDESJSON(.ERRORS,244)
Q
;
BUILDRETURN(HASHREC,ISODATE) ;build json return
N CLNCNT,CLIN,CLINICHASHDATE
S CLNCNT=0
S CLIN=0
F S CLIN=$O(^SC(CLIN)) Q:+CLIN=0 D
. Q:($E($$GET1^DIQ(44,CLIN,.01,"E"),1,2)="ZZ")!($$GET1^DIQ(44,CLIN,.01,"E")="")
. S CLINICHASHDATE=$$GET1^DIQ(44,CLIN,2901,"I")
. I ((ISODATE'="")&(ISODATE<CLINICHASHDATE))!(ISODATE="") D
. . S CLNCNT=CLNCNT+1
. . S HASHREC("Clinic",CLNCNT,"LastCacheTimestamp")=$$FMTISO^SDAMUTDT(CLINICHASHDATE,CLIN)
. . S HASHREC("Clinic",CLNCNT,"IEN")=CLIN
. . S HASHREC("Clinic",CLNCNT,"Hash")=$$GET1^DIQ(44,CLIN,2900,"I")
. . S HASHREC("Clinic",CLNCNT,"PbspID")=$$GET1^DIQ(44,CLIN,200,"E")
Q
;
GETCLINHASH(JSONRETURN,CLIN,SDEAS) ;return back the current stored hash for clinic
N SDHASERROR,HASHREC
D VALIDATECLIN(.SDHASERROR,CLIN)
D VALIDATEEAS(.SDHASERROR,.SDEAS)
I '$D(SDHASERROR) D
. S HASHREC("Clinic",1,"LastCacheTimestamp")=$$FMTISO^SDAMUTDT($$GET1^DIQ(44,CLIN,2901,"I"),CLIN)
. S HASHREC("Clinic",1,"IEN")=CLIN
. S HASHREC("Clinic",1,"Hash")=$$GET1^DIQ(44,CLIN,2900,"I")
. S HASHREC("Clinic",1,"PbspID")=$$GET1^DIQ(44,CLIN,200,"E")
I $D(SDHASERROR) D
. M HASHREC=SDHASERROR
D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.HASHREC)
Q
;
VALIDATEEAS(ERRORS,EAS) ;
S EAS=$G(EAS)
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL($G(EAS))
I $P($G(EAS),U)=-1 D ERRLOG^SDESJSON(.ERRORS,142)
Q
;
GETHASHONECLINIC(JSONRETURN,CLIN) ;hash one clinic, do not store new hash
N SDHASERROR,HASHREC
D VALIDATECLIN(.SDHASERROR,$G(CLIN))
I '$D(SDHASERROR) D
. D BLDCLNREC(.CLINRET,CLIN)
. D BUILDONERETURN(.HASHREC,CLIN)
. S HASHREC("Clinic",1,"NonstoredCacheTimestamp")=$$FMTISO^SDAMUTDT(CLINICHASHDATE,CLIN)
. S HASHREC("Clinic",1,"IEN")=CLIN
. S HASHREC("Clinic",1,"Hash")=$$SHAN^XLFSHAN(160,CLINRET(1))
. K ^TMP($J,"XLFMSG")
I $D(SDHASERROR) D
. M HASHREC=SDHASERROR
D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.HASHREC)
Q
;
VALIDATECLIN(ERRORS,CLIN) ;validate passed in clinic
I CLIN="" D ERRLOG^SDESJSON(.ERRORS,18) Q
I '$D(^SC(CLIN,0)) D ERRLOG^SDESJSON(.ERRORS,19) Q
Q
;
BUILDONERETURN(HASHREC,CLIN) ; builds json for given clinic
S CLINICHASHDATE=$$GET1^DIQ(44,CLIN,2901,"I")
S HASHREC("Clinic",1,"LastCacheTimestamp")=$$FMTISO^SDAMUTDT(CLINICHASHDATE,CLIN)
S HASHREC("Clinic",1,"IEN")=CLIN
S HASHREC("Clinic",1,"Hash")=$$SHAN^XLFSHAN(160,CLINRET(1))
Q
;
UPDTHASHONECLIN(JSONRETURN,CLIN,SDEAS) ;Create hash and update file, returns back hash for clinic
N SDHASERROR,FDA,FDAERR,HASHREC,TMPCNT
S TMPCNT=0
D VALIDATECLIN(.SDHASERROR,CLIN)
D VALIDATEEAS(.SDHASERROR,.SDEAS)
I '$D(SDHASERROR) D
. D BLDCLNREC(.CLINRET,CLIN,.TMPCNT)
. S FDA(44,CLIN_",",2900)=$$LSHAN^XLFSHAN(160,"XLFMSG",TMPCNT)
. S FDA(44,CLIN_",",2901)=$$NOW^XLFDT
. D FILE^DIE(,"FDA","FDAERR") K FDA
. S HASHREC("Clinic",1,"LastCacheTimestamp")=$$FMTISO^SDAMUTDT($$GET1^DIQ(44,CLIN,2901,"I"),CLIN)
. S HASHREC("Clinic",1,"IEN")=CLIN
. S HASHREC("Clinic",1,"Hash")=$$GET1^DIQ(44,CLIN,2900,"I")
. K ^TMP($J,"XLFMSG")
I $D(SDHASERROR) D
. M HASHREC=SDHASERROR
D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.HASHREC)
Q
;
BLDCLNREC(SDCLNJSON,SDCLNIEN,TMPCNT) ;Get Clinic data
;
N SDFIELDS,SDDATA,SDMSG,SDX,SDC,TIMEZONE,SDCLNSREC
S SDFIELDS=".01;1;3.5;8;9;10;24;60;61;62;200;1914;2502;2504;2505;2506;2507;2802;99;2000;2000.5;2801;30;2001;2002;1918.5;2503;2500;1916;1918;20;21;1912;1913;1917"
D GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
S SDCLNSREC("Clinic","ClinicIEN")=$G(SDCLNIEN) ;Clinic IEN
S SDCLNSREC("Clinic","ClinicName")=$G(SDDATA(44,SDCLNIEN_",",.01,"E")) ;Clinic Name
S SDCLNSREC("Clinic","Abbreviation")=$G(SDDATA(44,SDCLNIEN_",",1,"E")) ;Clinic Abbreviation
S SDCLNSREC("Clinic","PatientFriendlyName")=$G(SDDATA(44,SDCLNIEN_",",60,"E")) ;Patient Friendly Name
S SDCLNSREC("Clinic","MeetsAtThisFacility")=$G(SDDATA(44,SDCLNIEN_",",2504,"E")) ;Clinic meets at this facility?
S SDCLNSREC("Clinic","AllowPatScheduling")=$G(SDDATA(44,SDCLNIEN_",",61,"E")) ;Allow Direct Patient Scheduling?
S SDCLNSREC("Clinic","DisplayClinicAppt")=$G(SDDATA(44,SDCLNIEN_",",62,"E")) ;DISPLAY CLIN APPT TO PATIENTS?
S SDCLNSREC("Clinic","Service")=$G(SDDATA(44,SDCLNIEN_",",9,"E")) ;Service
S SDCLNSREC("Clinic","NonCountClinic")=$G(SDDATA(44,SDCLNIEN_",",2502,"E")) ;NON-COUNT CLINIC? (Y OR N)
S SDCLNSREC("Clinic","DivisionIEN")=$G(SDDATA(44,SDCLNIEN_",",3.5,"I")) ;Division
S SDCLNSREC("Clinic","StopCodeNum")=$G(SDDATA(44,SDCLNIEN_",",8,"I")) ;Stop Code Number
S SDCLNSREC("Clinic","DefaultApptType")=$G(SDDATA(44,SDCLNIEN_",",2507,"E")) ;Default Appointment type
S SDCLNSREC("Clinic","AdminInpatientMeds")=$G(SDDATA(44,SDCLNIEN_",",2802,"E")) ;ADMINISTER INPATIENT MEDS?
S SDCLNSREC("Clinic","Telephone")=$G(SDDATA(44,SDCLNIEN_",",99,"E")) ;TELEPHONE
S SDCLNSREC("Clinic","ReqXrayFilms")=$G(SDDATA(44,SDCLNIEN_",",2000,"E")) ;REQUIRE X-RAY FILMS?
S SDCLNSREC("Clinic","ReqActionProfiles")=$G(SDDATA(44,SDCLNIEN_",",2000.5,"E")) ;REQUIRE ACTION PROFILES?
S SDCLNSREC("Clinic","CheckinCheckoutTime")=$G(SDDATA(44,SDCLNIEN_",",24,"E")) ;ASK FOR CHECK IN/OUT TIME
S SDCLNSREC("Clinic","DefaultToPCPractitioner")=$G(SDDATA(44,SDCLNIEN_",",2801,"E")) ;DEFAULT TO PC PRACTITIONER?
S SDCLNSREC("Clinic","WorkloadValidationCheckout")=$G(SDDATA(44,SDCLNIEN_",",30,"E")) ;WORKLOAD VALIDATION AT CHK OUT
S SDCLNSREC("Clinic","AllowableConsecutiveNoShows")=$G(SDDATA(44,SDCLNIEN_",",2001,"E")) ;ALLOWABLE CONSECUTIVE NO-SHOWS
S SDCLNSREC("Clinic","MaxDaysForFutureBooking")=$G(SDDATA(44,SDCLNIEN_",",2002,"E")) ;MAX # DAYS FOR FUTURE BOOKING
S SDCLNSREC("Clinic","HolidaySchedule")=$G(SDDATA(44,SDCLNIEN_",",1918.5,"E")) ;SCHEDULE ON HOLIDAYS?
S SDCLNSREC("Clinic","CreditStopCodeNum")=$G(SDDATA(44,SDCLNIEN_",",2503,"I")) ;CREDIT STOP CODE
S SDCLNSREC("Clinic","ProhibitAccessToClinic")=$G(SDDATA(44,SDCLNIEN_",",2500,"E")) ;PROHIBIT ACCESS TO CLINIC?
S SDCLNSREC("Clinic","PhysicalLocation")=$G(SDDATA(44,SDCLNIEN_",",10,"E")) ;PHYSICAL LOCATION
S SDCLNSREC("Clinic","Principal")=$G(SDDATA(44,SDCLNIEN_",",1916,"E")) ;PRINCIPAL Clinic
S SDCLNSREC("Clinic","OverbooksPerDayMax")=$G(SDDATA(44,SDCLNIEN_",",1918,"E")) ;OVERBOOKS/DAY MAXIMUM
S SDCLNSREC("Clinic","ECheckinAllowed")=$G(SDDATA(44,SDCLNIEN_",",20,"E")) ;E-CHECKIN ALLOWED
S SDCLNSREC("Clinic","PreCheckinAllowed")=$G(SDDATA(44,SDCLNIEN_",",21,"E")) ;PRE-CHECKIN ALLOWED NO
S SDCLNSREC("Clinic","LengthOfAppt")=$G(SDDATA(44,SDCLNIEN_",",1912,"E")) ;LENGTH OF APP'T
S SDCLNSREC("Clinic","VariableApptLength")=$G(SDDATA(44,SDCLNIEN_",",1913,"E")) ;VARIABLE APP'NTMENT LENGTH
S SDCLNSREC("Clinic","IncrementsPerHr")=$G(SDDATA(44,SDCLNIEN_",",1917,"E")) ;DISPLAY INCREMENTS PER HOUR
S SDCLNSREC("Clinic","HourClinicDisplayBegins")=$S($G(SDDATA(44,SDCLNIEN_",",1914,"E"))'="":$G(SDDATA(44,SDCLNIEN_",",1914,"E")),1:8) ; HOUR CLINIC DISPLAY BEGINS
S SDCLNSREC("Clinic","PbspID")=$G(SDDATA(44,SDCLNIEN_",",200,"I")) ;PBSPID
S TIMEZONE=$$TIMEZONEDATA^SDESUTIL($G(SDCLNIEN)),TIMEZONE=$P($G(TIMEZONE),U)
S SDCLNSREC("Clinic","Timezone")=TIMEZONE
S SDCLNSREC("Clinic","Inactivate Date")=$G(SDDATA(44,SDCLNIEN_",",2505,"I")) ;Inactivate Date
S SDCLNSREC("Clinic","Reactivate Date")=$G(SDDATA(44,SDCLNIEN_",",2506,"I")) ;Reactivate Date
; Get CHAR4 Data
N CHAR4
S CHAR4=$$CHAR4^SDESUTIL($G(SDDATA(44,SDCLNIEN_",",.01,"E")))
S SDCLNSREC("Clinic","CHAR4")=CHAR4
; Special Instructions Multiple
S SDX="",SDC=0
S SDFIELDS="1910*"
K SDDATA,SDMSG
D GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"E","SDDATA","SDMSG")
F S SDX=$O(SDDATA(44.03,SDX)) Q:SDX="" D
. S SDC=SDC+1
. S SDCLNSREC("Clinic","Special Instructions",SDC)=$G(SDDATA(44.03,SDX,.01,"E"))
; Providers Multiple
S SDX="",SDC=0
S SDFIELDS="2600*"
K SDDATA,SDMSG
D GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"E","SDDATA","SDMSG")
F S SDX=$O(SDDATA(44.1,SDX)) Q:SDX="" D
. S SDC=SDC+1
. S SDCLNSREC("Clinic","Provider",SDC,"Name")=$G(SDDATA(44.1,SDX,.01,"E"))
. S SDCLNSREC("Clinic","Provider",SDC,"DefaultForClinic")=$G(SDDATA(44.1,SDX,.02,"E"))
; Diagnosis Multiple
S SDX="",SDC=0
S SDFIELDS="2700*"
K SDDATA,SDMSG
D GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"E","SDDATA","SDMSG")
F S SDX=$O(SDDATA(44.11,SDX)) Q:SDX="" D
. S SDC=SDC+1
. S SDCLNSREC("Clinic","Diagnosis",SDC,"Code")=$G(SDDATA(44.11,SDX,.01,"E"))
. S SDCLNSREC("Clinic","Diagnosis",SDC,"DefaultForClinic")=$G(SDDATA(44.11,SDX,.02,"E"))
; Privileged User Multiple (#2501)
S SDX="",SDC=0
S SDFIELDS="2501*"
K SDDATA,SDMSG
D GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
F S SDX=$O(SDDATA(44.04,SDX)) Q:SDX="" D
. S SDC=SDC+1
. S SDCLNSREC("Clinic","PrivilegedUser",SDC,"IEN")=$G(SDDATA(44.04,SDX,.01,"I"))
. S SDCLNSREC("Clinic","PrivilegedUser",SDC,"Name")=$G(SDDATA(44.04,SDX,.01,"E"))
D BUILDJSON^SDESBUILDJSON(.SDCLNJSON,.SDCLNSREC)
D SETTOTMP(.SDCLNJSON,.TMPCNT)
Q
;
SETTOTMP(SDCLNJSON,TMPCNT) ;
K ^TMP($J,"XLFMSG")
N I,IEN,START,END,EXTEND
S IEN="",TMPCNT=$G(TMPCNT,0)
F S IEN=$O(SDCLNJSON(IEN)) Q:'IEN D
.I TMPCNT>1,($L($G(^TMP($J,"XLFMSG",TMPCNT)))<64) D COMBINE(.SDCLNJSON,TMPCNT)
.S END=($L(SDCLNJSON(IEN))\64)+1
.S END=(END*64)+1
.F I=1:64:END D
..I I=1 S START=I Q
..S EXTEND=I
..I $E(SDCLNJSON(IEN),START,EXTEND-1)'="" S TMPCNT=TMPCNT+1,^TMP($J,"XLFMSG",TMPCNT)=$E(SDCLNJSON(IEN),START,EXTEND-1)
..S START=I
Q
;
COMBINE(SDCLNJSON,TMPCNT) ;
N CURLEN,EXTRA
S CURLEN=$L($G(^TMP($J,"XLFMSG",TMPCNT)))
S EXTRA=64-CURLEN
S ^TMP($J,"XLFMSG",TMPCNT)=^TMP($J,"XLFMSG",TMPCNT)_$E(SDCLNJSON(IEN),1,EXTRA)
S SDCLNJSON(IEN)=$E(SDCLNJSON(IEN),EXTRA+1,99999)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESHASHCLIN 11011 printed Dec 13, 2024@02:57:15 Page 2
SDESHASHCLIN ;ALB/LAB,MGD,BWF - VISTA SCHEDULING RPCS HASH CLINIC ;Nov 14, 2022
+1 ;;5.3;Scheduling;**823,824,828,871**;Aug 13, 1993;Build 13
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 QUIT
+4 ;
HASHALL ;hash all clinics this will be a jobbed option: SDES HASH ALL CLINICS
+1 NEW CLINIC,CNT,LISTOFHASH,FDA,FDAERR,TMPCNT
+2 SET (CLIN,CNT)=0
+3 FOR
SET CLIN=$ORDER(^SC(CLIN))
if (+CLIN=0)
QUIT
Begin DoDot:1
+4 if $EXTRACT($$GET1^DIQ(44,CLIN,.01,"E"),1,2)="ZZ"
QUIT
+5 KILL X,CLINRET
+6 SET CNT=CNT+1
SET TMPCNT=0
+7 DO BLDCLNREC(.CLINRET,CLIN,.TMPCNT)
+8 SET FDA(44,CLIN_",",2900)=$$LSHAN^XLFSHAN(160,"XLFMSG",TMPCNT)
+9 SET FDA(44,CLIN_",",2901)=$$NOW^XLFDT
+10 DO FILE^DIE(,"FDA","FDAERR")
KILL FDA
+11 KILL ^TMP($JOB,"XLFMSG")
End DoDot:1
+12 QUIT
+13 ;
GETALLHASHCLIN(JSONRETURN,ISODATE,SDEAS) ;get all get clinic's hash value
+1 ;if date passed in, then will return all clinics that have been hashed since the date/time passed in.
+2 ;date is in ISO 8601 format.
+3 NEW HASHREC,SDHASERROR
+4 DO VALIDATEDATE(.SDHASERROR,.ISODATE)
+5 DO VALIDATEEAS(.SDHASERROR,.SDEAS)
+6 IF '$DATA(SDHASERROR)
Begin DoDot:1
+7 DO BUILDRETURN(.HASHREC,ISODATE)
End DoDot:1
+8 IF $DATA(SDHASERROR)
Begin DoDot:1
+9 MERGE HASHREC=SDHASERROR
End DoDot:1
+10 DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.HASHREC)
+11 QUIT
+12 ;
VALIDATEDATE(ERRORS,ISODATE) ;validate incoming date, convert to FileMan Format
+1 SET ISODATE=$GET(ISODATE)
+2 IF ISODATE'=""
SET ISODATE=$$ISOTFM^SDAMUTDT(ISODATE)
+3 IF ISODATE=-1
DO ERRLOG^SDESJSON(.ERRORS,244)
+4 QUIT
+5 ;
BUILDRETURN(HASHREC,ISODATE) ;build json return
+1 NEW CLNCNT,CLIN,CLINICHASHDATE
+2 SET CLNCNT=0
+3 SET CLIN=0
+4 FOR
SET CLIN=$ORDER(^SC(CLIN))
if +CLIN=0
QUIT
Begin DoDot:1
+5 if ($EXTRACT($$GET1^DIQ(44,CLIN,.01,"E"),1,2)="ZZ")!($$GET1^DIQ(44,CLIN,.01,"E")="")
QUIT
+6 SET CLINICHASHDATE=$$GET1^DIQ(44,CLIN,2901,"I")
+7 IF ((ISODATE'="")&(ISODATE<CLINICHASHDATE))!(ISODATE="")
Begin DoDot:2
+8 SET CLNCNT=CLNCNT+1
+9 SET HASHREC("Clinic",CLNCNT,"LastCacheTimestamp")=$$FMTISO^SDAMUTDT(CLINICHASHDATE,CLIN)
+10 SET HASHREC("Clinic",CLNCNT,"IEN")=CLIN
+11 SET HASHREC("Clinic",CLNCNT,"Hash")=$$GET1^DIQ(44,CLIN,2900,"I")
+12 SET HASHREC("Clinic",CLNCNT,"PbspID")=$$GET1^DIQ(44,CLIN,200,"E")
End DoDot:2
End DoDot:1
+13 QUIT
+14 ;
GETCLINHASH(JSONRETURN,CLIN,SDEAS) ;return back the current stored hash for clinic
+1 NEW SDHASERROR,HASHREC
+2 DO VALIDATECLIN(.SDHASERROR,CLIN)
+3 DO VALIDATEEAS(.SDHASERROR,.SDEAS)
+4 IF '$DATA(SDHASERROR)
Begin DoDot:1
+5 SET HASHREC("Clinic",1,"LastCacheTimestamp")=$$FMTISO^SDAMUTDT($$GET1^DIQ(44,CLIN,2901,"I"),CLIN)
+6 SET HASHREC("Clinic",1,"IEN")=CLIN
+7 SET HASHREC("Clinic",1,"Hash")=$$GET1^DIQ(44,CLIN,2900,"I")
+8 SET HASHREC("Clinic",1,"PbspID")=$$GET1^DIQ(44,CLIN,200,"E")
End DoDot:1
+9 IF $DATA(SDHASERROR)
Begin DoDot:1
+10 MERGE HASHREC=SDHASERROR
End DoDot:1
+11 DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.HASHREC)
+12 QUIT
+13 ;
VALIDATEEAS(ERRORS,EAS) ;
+1 SET EAS=$GET(EAS)
+2 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL($GET(EAS))
+3 IF $PIECE($GET(EAS),U)=-1
DO ERRLOG^SDESJSON(.ERRORS,142)
+4 QUIT
+5 ;
GETHASHONECLINIC(JSONRETURN,CLIN) ;hash one clinic, do not store new hash
+1 NEW SDHASERROR,HASHREC
+2 DO VALIDATECLIN(.SDHASERROR,$GET(CLIN))
+3 IF '$DATA(SDHASERROR)
Begin DoDot:1
+4 DO BLDCLNREC(.CLINRET,CLIN)
+5 DO BUILDONERETURN(.HASHREC,CLIN)
+6 SET HASHREC("Clinic",1,"NonstoredCacheTimestamp")=$$FMTISO^SDAMUTDT(CLINICHASHDATE,CLIN)
+7 SET HASHREC("Clinic",1,"IEN")=CLIN
+8 SET HASHREC("Clinic",1,"Hash")=$$SHAN^XLFSHAN(160,CLINRET(1))
+9 KILL ^TMP($JOB,"XLFMSG")
End DoDot:1
+10 IF $DATA(SDHASERROR)
Begin DoDot:1
+11 MERGE HASHREC=SDHASERROR
End DoDot:1
+12 DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.HASHREC)
+13 QUIT
+14 ;
VALIDATECLIN(ERRORS,CLIN) ;validate passed in clinic
+1 IF CLIN=""
DO ERRLOG^SDESJSON(.ERRORS,18)
QUIT
+2 IF '$DATA(^SC(CLIN,0))
DO ERRLOG^SDESJSON(.ERRORS,19)
QUIT
+3 QUIT
+4 ;
BUILDONERETURN(HASHREC,CLIN) ; builds json for given clinic
+1 SET CLINICHASHDATE=$$GET1^DIQ(44,CLIN,2901,"I")
+2 SET HASHREC("Clinic",1,"LastCacheTimestamp")=$$FMTISO^SDAMUTDT(CLINICHASHDATE,CLIN)
+3 SET HASHREC("Clinic",1,"IEN")=CLIN
+4 SET HASHREC("Clinic",1,"Hash")=$$SHAN^XLFSHAN(160,CLINRET(1))
+5 QUIT
+6 ;
UPDTHASHONECLIN(JSONRETURN,CLIN,SDEAS) ;Create hash and update file, returns back hash for clinic
+1 NEW SDHASERROR,FDA,FDAERR,HASHREC,TMPCNT
+2 SET TMPCNT=0
+3 DO VALIDATECLIN(.SDHASERROR,CLIN)
+4 DO VALIDATEEAS(.SDHASERROR,.SDEAS)
+5 IF '$DATA(SDHASERROR)
Begin DoDot:1
+6 DO BLDCLNREC(.CLINRET,CLIN,.TMPCNT)
+7 SET FDA(44,CLIN_",",2900)=$$LSHAN^XLFSHAN(160,"XLFMSG",TMPCNT)
+8 SET FDA(44,CLIN_",",2901)=$$NOW^XLFDT
+9 DO FILE^DIE(,"FDA","FDAERR")
KILL FDA
+10 SET HASHREC("Clinic",1,"LastCacheTimestamp")=$$FMTISO^SDAMUTDT($$GET1^DIQ(44,CLIN,2901,"I"),CLIN)
+11 SET HASHREC("Clinic",1,"IEN")=CLIN
+12 SET HASHREC("Clinic",1,"Hash")=$$GET1^DIQ(44,CLIN,2900,"I")
+13 KILL ^TMP($JOB,"XLFMSG")
End DoDot:1
+14 IF $DATA(SDHASERROR)
Begin DoDot:1
+15 MERGE HASHREC=SDHASERROR
End DoDot:1
+16 DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.HASHREC)
+17 QUIT
+18 ;
BLDCLNREC(SDCLNJSON,SDCLNIEN,TMPCNT) ;Get Clinic data
+1 ;
+2 NEW SDFIELDS,SDDATA,SDMSG,SDX,SDC,TIMEZONE,SDCLNSREC
+3 SET SDFIELDS=".01;1;3.5;8;9;10;24;60;61;62;200;1914;2502;2504;2505;2506;2507;2802;99;2000;2000.5;2801;30;2001;2002;1918.5;2503;2500;1916;1918;20;21;1912;1913;1917"
+4 DO GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
+5 ;Clinic IEN
SET SDCLNSREC("Clinic","ClinicIEN")=$GET(SDCLNIEN)
+6 ;Clinic Name
SET SDCLNSREC("Clinic","ClinicName")=$GET(SDDATA(44,SDCLNIEN_",",.01,"E"))
+7 ;Clinic Abbreviation
SET SDCLNSREC("Clinic","Abbreviation")=$GET(SDDATA(44,SDCLNIEN_",",1,"E"))
+8 ;Patient Friendly Name
SET SDCLNSREC("Clinic","PatientFriendlyName")=$GET(SDDATA(44,SDCLNIEN_",",60,"E"))
+9 ;Clinic meets at this facility?
SET SDCLNSREC("Clinic","MeetsAtThisFacility")=$GET(SDDATA(44,SDCLNIEN_",",2504,"E"))
+10 ;Allow Direct Patient Scheduling?
SET SDCLNSREC("Clinic","AllowPatScheduling")=$GET(SDDATA(44,SDCLNIEN_",",61,"E"))
+11 ;DISPLAY CLIN APPT TO PATIENTS?
SET SDCLNSREC("Clinic","DisplayClinicAppt")=$GET(SDDATA(44,SDCLNIEN_",",62,"E"))
+12 ;Service
SET SDCLNSREC("Clinic","Service")=$GET(SDDATA(44,SDCLNIEN_",",9,"E"))
+13 ;NON-COUNT CLINIC? (Y OR N)
SET SDCLNSREC("Clinic","NonCountClinic")=$GET(SDDATA(44,SDCLNIEN_",",2502,"E"))
+14 ;Division
SET SDCLNSREC("Clinic","DivisionIEN")=$GET(SDDATA(44,SDCLNIEN_",",3.5,"I"))
+15 ;Stop Code Number
SET SDCLNSREC("Clinic","StopCodeNum")=$GET(SDDATA(44,SDCLNIEN_",",8,"I"))
+16 ;Default Appointment type
SET SDCLNSREC("Clinic","DefaultApptType")=$GET(SDDATA(44,SDCLNIEN_",",2507,"E"))
+17 ;ADMINISTER INPATIENT MEDS?
SET SDCLNSREC("Clinic","AdminInpatientMeds")=$GET(SDDATA(44,SDCLNIEN_",",2802,"E"))
+18 ;TELEPHONE
SET SDCLNSREC("Clinic","Telephone")=$GET(SDDATA(44,SDCLNIEN_",",99,"E"))
+19 ;REQUIRE X-RAY FILMS?
SET SDCLNSREC("Clinic","ReqXrayFilms")=$GET(SDDATA(44,SDCLNIEN_",",2000,"E"))
+20 ;REQUIRE ACTION PROFILES?
SET SDCLNSREC("Clinic","ReqActionProfiles")=$GET(SDDATA(44,SDCLNIEN_",",2000.5,"E"))
+21 ;ASK FOR CHECK IN/OUT TIME
SET SDCLNSREC("Clinic","CheckinCheckoutTime")=$GET(SDDATA(44,SDCLNIEN_",",24,"E"))
+22 ;DEFAULT TO PC PRACTITIONER?
SET SDCLNSREC("Clinic","DefaultToPCPractitioner")=$GET(SDDATA(44,SDCLNIEN_",",2801,"E"))
+23 ;WORKLOAD VALIDATION AT CHK OUT
SET SDCLNSREC("Clinic","WorkloadValidationCheckout")=$GET(SDDATA(44,SDCLNIEN_",",30,"E"))
+24 ;ALLOWABLE CONSECUTIVE NO-SHOWS
SET SDCLNSREC("Clinic","AllowableConsecutiveNoShows")=$GET(SDDATA(44,SDCLNIEN_",",2001,"E"))
+25 ;MAX # DAYS FOR FUTURE BOOKING
SET SDCLNSREC("Clinic","MaxDaysForFutureBooking")=$GET(SDDATA(44,SDCLNIEN_",",2002,"E"))
+26 ;SCHEDULE ON HOLIDAYS?
SET SDCLNSREC("Clinic","HolidaySchedule")=$GET(SDDATA(44,SDCLNIEN_",",1918.5,"E"))
+27 ;CREDIT STOP CODE
SET SDCLNSREC("Clinic","CreditStopCodeNum")=$GET(SDDATA(44,SDCLNIEN_",",2503,"I"))
+28 ;PROHIBIT ACCESS TO CLINIC?
SET SDCLNSREC("Clinic","ProhibitAccessToClinic")=$GET(SDDATA(44,SDCLNIEN_",",2500,"E"))
+29 ;PHYSICAL LOCATION
SET SDCLNSREC("Clinic","PhysicalLocation")=$GET(SDDATA(44,SDCLNIEN_",",10,"E"))
+30 ;PRINCIPAL Clinic
SET SDCLNSREC("Clinic","Principal")=$GET(SDDATA(44,SDCLNIEN_",",1916,"E"))
+31 ;OVERBOOKS/DAY MAXIMUM
SET SDCLNSREC("Clinic","OverbooksPerDayMax")=$GET(SDDATA(44,SDCLNIEN_",",1918,"E"))
+32 ;E-CHECKIN ALLOWED
SET SDCLNSREC("Clinic","ECheckinAllowed")=$GET(SDDATA(44,SDCLNIEN_",",20,"E"))
+33 ;PRE-CHECKIN ALLOWED NO
SET SDCLNSREC("Clinic","PreCheckinAllowed")=$GET(SDDATA(44,SDCLNIEN_",",21,"E"))
+34 ;LENGTH OF APP'T
SET SDCLNSREC("Clinic","LengthOfAppt")=$GET(SDDATA(44,SDCLNIEN_",",1912,"E"))
+35 ;VARIABLE APP'NTMENT LENGTH
SET SDCLNSREC("Clinic","VariableApptLength")=$GET(SDDATA(44,SDCLNIEN_",",1913,"E"))
+36 ;DISPLAY INCREMENTS PER HOUR
SET SDCLNSREC("Clinic","IncrementsPerHr")=$GET(SDDATA(44,SDCLNIEN_",",1917,"E"))
+37 ; HOUR CLINIC DISPLAY BEGINS
SET SDCLNSREC("Clinic","HourClinicDisplayBegins")=$SELECT($GET(SDDATA(44,SDCLNIEN_",",1914,"E"))'="":$GET(SDDATA(44,SDCLNIEN_",",1914,"E")),1:8)
+38 ;PBSPID
SET SDCLNSREC("Clinic","PbspID")=$GET(SDDATA(44,SDCLNIEN_",",200,"I"))
+39 SET TIMEZONE=$$TIMEZONEDATA^SDESUTIL($GET(SDCLNIEN))
SET TIMEZONE=$PIECE($GET(TIMEZONE),U)
+40 SET SDCLNSREC("Clinic","Timezone")=TIMEZONE
+41 ;Inactivate Date
SET SDCLNSREC("Clinic","Inactivate Date")=$GET(SDDATA(44,SDCLNIEN_",",2505,"I"))
+42 ;Reactivate Date
SET SDCLNSREC("Clinic","Reactivate Date")=$GET(SDDATA(44,SDCLNIEN_",",2506,"I"))
+43 ; Get CHAR4 Data
+44 NEW CHAR4
+45 SET CHAR4=$$CHAR4^SDESUTIL($GET(SDDATA(44,SDCLNIEN_",",.01,"E")))
+46 SET SDCLNSREC("Clinic","CHAR4")=CHAR4
+47 ; Special Instructions Multiple
+48 SET SDX=""
SET SDC=0
+49 SET SDFIELDS="1910*"
+50 KILL SDDATA,SDMSG
+51 DO GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"E","SDDATA","SDMSG")
+52 FOR
SET SDX=$ORDER(SDDATA(44.03,SDX))
if SDX=""
QUIT
Begin DoDot:1
+53 SET SDC=SDC+1
+54 SET SDCLNSREC("Clinic","Special Instructions",SDC)=$GET(SDDATA(44.03,SDX,.01,"E"))
End DoDot:1
+55 ; Providers Multiple
+56 SET SDX=""
SET SDC=0
+57 SET SDFIELDS="2600*"
+58 KILL SDDATA,SDMSG
+59 DO GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"E","SDDATA","SDMSG")
+60 FOR
SET SDX=$ORDER(SDDATA(44.1,SDX))
if SDX=""
QUIT
Begin DoDot:1
+61 SET SDC=SDC+1
+62 SET SDCLNSREC("Clinic","Provider",SDC,"Name")=$GET(SDDATA(44.1,SDX,.01,"E"))
+63 SET SDCLNSREC("Clinic","Provider",SDC,"DefaultForClinic")=$GET(SDDATA(44.1,SDX,.02,"E"))
End DoDot:1
+64 ; Diagnosis Multiple
+65 SET SDX=""
SET SDC=0
+66 SET SDFIELDS="2700*"
+67 KILL SDDATA,SDMSG
+68 DO GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"E","SDDATA","SDMSG")
+69 FOR
SET SDX=$ORDER(SDDATA(44.11,SDX))
if SDX=""
QUIT
Begin DoDot:1
+70 SET SDC=SDC+1
+71 SET SDCLNSREC("Clinic","Diagnosis",SDC,"Code")=$GET(SDDATA(44.11,SDX,.01,"E"))
+72 SET SDCLNSREC("Clinic","Diagnosis",SDC,"DefaultForClinic")=$GET(SDDATA(44.11,SDX,.02,"E"))
End DoDot:1
+73 ; Privileged User Multiple (#2501)
+74 SET SDX=""
SET SDC=0
+75 SET SDFIELDS="2501*"
+76 KILL SDDATA,SDMSG
+77 DO GETS^DIQ(44,SDCLNIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
+78 FOR
SET SDX=$ORDER(SDDATA(44.04,SDX))
if SDX=""
QUIT
Begin DoDot:1
+79 SET SDC=SDC+1
+80 SET SDCLNSREC("Clinic","PrivilegedUser",SDC,"IEN")=$GET(SDDATA(44.04,SDX,.01,"I"))
+81 SET SDCLNSREC("Clinic","PrivilegedUser",SDC,"Name")=$GET(SDDATA(44.04,SDX,.01,"E"))
End DoDot:1
+82 DO BUILDJSON^SDESBUILDJSON(.SDCLNJSON,.SDCLNSREC)
+83 DO SETTOTMP(.SDCLNJSON,.TMPCNT)
+84 QUIT
+85 ;
SETTOTMP(SDCLNJSON,TMPCNT) ;
+1 KILL ^TMP($JOB,"XLFMSG")
+2 NEW I,IEN,START,END,EXTEND
+3 SET IEN=""
SET TMPCNT=$GET(TMPCNT,0)
+4 FOR
SET IEN=$ORDER(SDCLNJSON(IEN))
if 'IEN
QUIT
Begin DoDot:1
+5 IF TMPCNT>1
IF ($LENGTH($GET(^TMP($JOB,"XLFMSG",TMPCNT)))<64)
DO COMBINE(.SDCLNJSON,TMPCNT)
+6 SET END=($LENGTH(SDCLNJSON(IEN))\64)+1
+7 SET END=(END*64)+1
+8 FOR I=1:64:END
Begin DoDot:2
+9 IF I=1
SET START=I
QUIT
+10 SET EXTEND=I
+11 IF $EXTRACT(SDCLNJSON(IEN),START,EXTEND-1)'=""
SET TMPCNT=TMPCNT+1
SET ^TMP($JOB,"XLFMSG",TMPCNT)=$EXTRACT(SDCLNJSON(IEN),START,EXTEND-1)
+12 SET START=I
End DoDot:2
End DoDot:1
+13 QUIT
+14 ;
COMBINE(SDCLNJSON,TMPCNT) ;
+1 NEW CURLEN,EXTRA
+2 SET CURLEN=$LENGTH($GET(^TMP($JOB,"XLFMSG",TMPCNT)))
+3 SET EXTRA=64-CURLEN
+4 SET ^TMP($JOB,"XLFMSG",TMPCNT)=^TMP($JOB,"XLFMSG",TMPCNT)_$EXTRACT(SDCLNJSON(IEN),1,EXTRA)
+5 SET SDCLNJSON(IEN)=$EXTRACT(SDCLNJSON(IEN),EXTRA+1,99999)
+6 QUIT