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

SDESHASHCLIN.m

Go to the documentation of this file.
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