SDES2SRCHCLNBYSC ;ALB/JAS - SDES2 SEARCH CLIN BY STOP CODE ;JUL 19, 2024
;;5.3;Scheduling;**886**;Aug 13, 1993;Build 13
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
;External References
;-------------------
; Reference to $$ACTIVPRV^PXAPI is supported by IA #2349
;
SEARCHCLIN(SDRETURN,SDCONTEXT,SDSEARCH) ;Search for clinics
; 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 SDSEARCH array contains the following array elements:
; SDSEARCH("STATION") (Opt) = Station Number: If present, the search would be limited to matching clinics at the given institution.
; If absent, the search would take place across all divisions/institutions. Example values: 534, 534GB.
; If "STARTING STOP CODE" is not populated, "STATION" will be REQUIRED.
; SDSEARCH("STARTING STOP CODE") (Opt) = The beginning range of Stop Codes to be included in the search. If "ENDING STOP CODE" is
; not populated, this will be the only Stop Code to be included in the search. If "STATION" is not populated, "STARTING STOP
; "CODE" is REQUIRED.
; SDSEARCH("ENDING STOP CODE") (Opt) = The ending range of Stop Codes to be included in the search.
; If populated, the "STARTING STOP CODE" value is REQUIRED.
;
; * Either "STATION" or "STARTING STOP CODE" must be populated.
;
; OUTPUT - SDRETURN
; List of Clinics from the HOSPITAL LOCATION (#44) file that meet the search criteria.
;
K ^TMP("SDES2SRCHCLNBYSC",$J)
N CLINLIST
S CLINLIST=$NA(^TMP("SDES2SRCHCLNBYSC",$J,"CLINLIST")) K @CLINLIST
S SDRETURN=$NA(^TMP("SDES2SRCHCLNBYSC",$J,"JSON")) K @SDRETURN
;
N SDERRORS
S SDSEARCH("SDDATETIME")=DT
;
D VALCONTEXT^SDES2VALCONTEXT(.SDERRORS,.SDCONTEXT)
I $D(SDERRORS) D Q
. S SDERRORS("ClinicAudit",1)="" M @CLINLIST=SDERRORS
. D ENCODE^XLFJSON(.CLINLIST,.SDRETURN) K @CLINLIST,CLINLIST,SDSEARCH("SDDATETIME")
;
D VALSRCHFLDS(.SDERRORS,.SDSEARCH)
I $D(SDERRORS) D Q
. S SDERRORS("ClinicAudit",1)="" M @CLINLIST=SDERRORS
. D ENCODE^XLFJSON(.CLINLIST,.SDRETURN) K @CLINLIST,CLINLIST,SDSEARCH("SDDATETIME")
;
D GETCLINICLIST(.CLINLIST,.SDSEARCH)
D ENCODE^XLFJSON(.CLINLIST,.SDRETURN)
K @CLINLIST,CLINLIST,SDSEARCH("SDDATETIME")
Q
;
VALSRCHFLDS(SDERRORS,SDSEARCH) ; validate incoming search parameters
; Input - SDERRORS = passed in by reference, represents the errors that could be generated when validating the search string
; STATION = Station Number for Division
; STARTING STOP CODE = Stop Code to search against or beginning of a Stop Code range, if ENDING STOP CODE is defined
; ENDING STOP CODE = The last Stop Code in a range to search against
N SDSTATION,STOPCDSTART,STOPCDEND
;
S SDSTATION=$G(SDSEARCH("STATION"))
I SDSTATION'="" D VALSTATIONNUM^SDES2VAL4(.SDERRORS,SDSTATION,DT)
Q:$D(SDERRORS)
;
S STOPCDSTART=$G(SDSEARCH("STARTING STOP CODE"))
S STOPCDEND=$G(SDSEARCH("ENDING STOP CODE"))
I $L(STOPCDSTART),'$D(^DIC(40.7,"C",STOPCDSTART)) D ERRLOG^SDESJSON(.SDERRORS,270) Q
I $L(STOPCDEND),'$D(^DIC(40.7,"C",STOPCDEND)) D ERRLOG^SDESJSON(.SDERRORS,270) Q
;
I STOPCDSTART=""&(STOPCDEND'="") D ERRLOG^SDESJSON(.SDERRORS,578) Q
I SDSTATION=""&(STOPCDSTART="") D ERRLOG^SDESJSON(.SDERRORS,577) Q
I STOPCDSTART'=""&(STOPCDEND'="")&(STOPCDSTART>STOPCDEND) D ERRLOG^SDESJSON(.SDERRORS,579) Q
;
Q
;
GETCLINICLIST(CLINLIST,SDSEARCH) ; pull matching clinics using the first input parameter passed in by the RPC
; Input -
; SDSEARCH = Search array values, including Station Number and/or Stop Code (Stop Code range)
; CLINLIST = passed in by reference; represents the temp global that will be returned as output
; Output - CLINLIST = Temp global with list of clinic names and clinic IENs.
N CLNIEN,SDCLINCNT,SDDATETIME,STOPCODESTART,STOPCODEEND,SDSTATION
S STOPCODESTART=$G(SDSEARCH("STARTING STOP CODE"))
S STOPCODEEND=$G(SDSEARCH("ENDING STOP CODE"))
S SDSTATION=$G(SDSEARCH("STATION"))
S SDDATETIME=$G(SDSEARCH("SDDATETIME"))
;
I $L(STOPCODESTART),'$L(STOPCODEEND) S STOPCODEEND=STOPCODESTART
;
S (CLNIEN,SDCLINCNT)=0
F S CLNIEN=$O(^SC(CLNIEN)) Q:'CLNIEN I $D(^SC(CLNIEN,0)) D
. I $L(SDSTATION) Q:$$WRONGDIVISION(CLNIEN,SDSTATION)
. Q:$$INACTIVE^SDES2UTIL(CLNIEN,SDDATETIME)
. I $L(STOPCODESTART) Q:$$WRONGSTOPCODE(CLNIEN,STOPCODESTART,STOPCODEEND)
. S SDCLINCNT=SDCLINCNT+1
. D BUILDRETURN(CLNIEN,SDCLINCNT,.CLINLIST,.SDDATETIME)
I SDCLINCNT=0 S @CLINLIST@("ClinicAudit",1)=""
Q
;
BUILDRETURN(SDCLINICIEN,SDCLINCNT,CLINLIST,SDDATETIME) ;Build return array with clinic data
; input - SDCLINICIEN = IEN of clinic in #44
; CLINLIST = passed by reference, represents the temp global of clinics and associated data that will be returned
; output - CLINLIST = clinic temp global and their associated data to be sent back to the client
;
N SDFIELDS,SDDATA,SDPRVCNT,SDCLINPROVIDER,SDPROVIDERID,SDPROVIDERNAME,SDDEFAULTPROV,SDPROVIDERSECID
N SDSICNT,SDSPECINIEN,SDSPECINSTRUCT
S SDFIELDS=".01;3.5;8;10;16;20;21;60;61;62;99;99.1;1912;1918;2002;2502;2503;2508;2509;2510;2511"
D GETS^DIQ(44,SDCLINICIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
S @CLINLIST@("ClinicAudit",SDCLINCNT,"ClinicIEN")=SDCLINICIEN
S @CLINLIST@("ClinicAudit",SDCLINCNT,"DivisionName")=$G(SDDATA(44,SDCLINICIEN_",",3.5,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"ClinicName")=$G(SDDATA(44,SDCLINICIEN_",",.01,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"PatientFriendlyName")=$G(SDDATA(44,SDCLINICIEN_",",60,"E"))
; initialize default provider fields to null to ensure they are always defined (in the event no default provider is found)
S @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderActive")=""
S @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderIEN")=""
S @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderName")=""
S @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderSecID")=""
S @CLINLIST@("ClinicAudit",SDCLINCNT,"StopCodeIEN")=$G(SDDATA(44,SDCLINICIEN_",",8,"I"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"StopCodeName")=$G(SDDATA(44,SDCLINICIEN_",",8,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"StopCodeAMIS")=$$GET1^DIQ(40.7,$G(SDDATA(44,SDCLINICIEN_",",8,"I")),1,"I")
S @CLINLIST@("ClinicAudit",SDCLINCNT,"CreditStopCodeIEN")=$G(SDDATA(44,SDCLINICIEN_",",2503,"I"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"CreditStopCodeName")=$G(SDDATA(44,SDCLINICIEN_",",2503,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"CreditStopCodeAMIS")=$$GET1^DIQ(40.7,$G(SDDATA(44,SDCLINICIEN_",",2503,"I")),1,"I")
S @CLINLIST@("ClinicAudit",SDCLINCNT,"NonCountClinic")=$G(SDDATA(44,SDCLINICIEN_",",2502,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"ECheckIn")=$G(SDDATA(44,SDCLINICIEN_",",20,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"PreCheckIn")=$G(SDDATA(44,SDCLINICIEN_",",21,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"PhysicalLocation")=$G(SDDATA(44,SDCLINICIEN_",",10,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"DirectScheduling")=$G(SDDATA(44,SDCLINICIEN_",",61,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"DisplayApptToPats")=$G(SDDATA(44,SDCLINICIEN_",",62,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"Telephone")=$$TELEPHONE^SDES2UTIL($G(SDDATA(44,SDCLINICIEN_",",99,"E")))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"TelephoneExt")=$$EXT^SDES2UTIL($G(SDDATA(44,SDCLINICIEN_",",99.1,"E")))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"ApptLength")=$G(SDDATA(44,SDCLINICIEN_",",1912,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"OverbooksPerDay")=$G(SDDATA(44,SDCLINICIEN_",",1918,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"MaxDaysForFuture")=$G(SDDATA(44,SDCLINICIEN_",",2002,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"NoShowLetter")=$G(SDDATA(44,SDCLINICIEN_",",2508,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"PreApptLetter")=$G(SDDATA(44,SDCLINICIEN_",",2509,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"ClinicCancelLetter")=$G(SDDATA(44,SDCLINICIEN_",",2510,"E"))
S @CLINLIST@("ClinicAudit",SDCLINCNT,"ApptCancelLetter")=$G(SDDATA(44,SDCLINICIEN_",",2511,"E"))
;
S SDSICNT=0
S SDSPECINIEN=0 F S SDSPECINIEN=$O(^SC(SDCLINICIEN,"SI",SDSPECINIEN)) Q:'SDSPECINIEN D
. S SDSPECINSTRUCT=$$GET1^DIQ(44.03,SDSPECINIEN_","_SDCLINICIEN_",",.01,"E")
. S SDSICNT=SDSICNT+1
. S @CLINLIST@("ClinicAudit",SDCLINCNT,"SpecialInstructions",SDSICNT,"InstructionText")=SDSPECINSTRUCT
; set empty object if no records are found
I '$D(@CLINLIST@("ClinicAudit",SDCLINCNT,"SpecialInstructions")) S @CLINLIST@("ClinicAudit",SDCLINCNT,"SpecialInstructions",1)=""
;
S SDPRVCNT=0
S SDCLINPROVIDER=0 F S SDCLINPROVIDER=$O(^SC(SDCLINICIEN,"PR",SDCLINPROVIDER)) Q:'SDCLINPROVIDER D
. S SDPROVIDERID=$$GET1^DIQ(44.1,SDCLINPROVIDER_","_SDCLINICIEN_",",.01,"I")
. S SDPROVIDERNAME=$$GET1^DIQ(200,SDPROVIDERID,.01,"E")
. S SDPROVIDERSECID=$$GET1^DIQ(200,SDPROVIDERID,205.1,"I")
. S SDDEFAULTPROV=$$GET1^DIQ(44.1,SDCLINPROVIDER_","_SDCLINICIEN_",",.02,"I")
. I SDDEFAULTPROV D Q
. . S @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderIEN")=SDPROVIDERID
. . S @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderName")=$$GET1^DIQ(200,SDPROVIDERID,.01,"E")
. . S @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderSecID")=SDPROVIDERSECID
. . S @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderActive")=$$ACTIVPRV^PXAPI(SDPROVIDERID,$G(SDDATETIME))
. S SDPRVCNT=SDPRVCNT+1
. S @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",SDPRVCNT,"Name")=SDPROVIDERNAME
. S @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",SDPRVCNT,"ID")=SDPROVIDERID
. S @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",SDPRVCNT,"SecID")=SDPROVIDERSECID
. S @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",SDPRVCNT,"Active")=$$ACTIVPRV^PXAPI(SDPROVIDERID,$G(SDDATETIME))
; set empty object if no records are found
I '$D(@CLINLIST@("ClinicAudit",SDCLINCNT,"Providers")) S @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",1)=""
Q
;
WRONGDIVISION(SDCLINICIEN,STATION) ;
; Screen out Clinics that don't match passed in Station Number
N SDDIVISION,FACNUM
S SDDIVISION=$$GET1^DIQ(44,SDCLINICIEN,3.5,"I")
S FACNUM=$$GET1^DIQ(40.8,SDDIVISION,1,"I")
I FACNUM'=STATION Q 1
Q 0
;
WRONGSTOPCODE(SDCLINICIEN,STOPCODESTART,STOPCODEEND) ;
; Screen out Clinics that don't match the passed in Stop Codes
N STOPCDIEN,STOPCODE
S STOPCDIEN=$$GET1^DIQ(44,SDCLINICIEN,8,"I")
S STOPCODE=$$GET1^DIQ(40.7,STOPCDIEN,1,"I")
I STOPCODE<STOPCODESTART!(STOPCODE>STOPCODEEND) Q 1
Q 0
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2SRCHCLNBYSC 10989 printed Nov 22, 2024@18:04:36 Page 2
SDES2SRCHCLNBYSC ;ALB/JAS - SDES2 SEARCH CLIN BY STOP CODE ;JUL 19, 2024
+1 ;;5.3;Scheduling;**886**;Aug 13, 1993;Build 13
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
+6 ;External References
+7 ;-------------------
+8 ; Reference to $$ACTIVPRV^PXAPI is supported by IA #2349
+9 ;
SEARCHCLIN(SDRETURN,SDCONTEXT,SDSEARCH) ;Search for clinics
+1 ; The SDCONTEXT array is controlled by the Acheron application and its fields are
+2 ; needed for the storage of the required auditing information.
+3 ;
+4 ; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
+5 ; SDCONTEXT("PATIENT DFN") = The DFN/IEN of the target patient from the calling application.
+6 ; SDCONTEXT("PATIENT ICN") = The ICN of the target patient from the calling application.
+7 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
+8 ; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
+9 ;
+10 ; The SDSEARCH array contains the following array elements:
+11 ; SDSEARCH("STATION") (Opt) = Station Number: If present, the search would be limited to matching clinics at the given institution.
+12 ; If absent, the search would take place across all divisions/institutions. Example values: 534, 534GB.
+13 ; If "STARTING STOP CODE" is not populated, "STATION" will be REQUIRED.
+14 ; SDSEARCH("STARTING STOP CODE") (Opt) = The beginning range of Stop Codes to be included in the search. If "ENDING STOP CODE" is
+15 ; not populated, this will be the only Stop Code to be included in the search. If "STATION" is not populated, "STARTING STOP
+16 ; "CODE" is REQUIRED.
+17 ; SDSEARCH("ENDING STOP CODE") (Opt) = The ending range of Stop Codes to be included in the search.
+18 ; If populated, the "STARTING STOP CODE" value is REQUIRED.
+19 ;
+20 ; * Either "STATION" or "STARTING STOP CODE" must be populated.
+21 ;
+22 ; OUTPUT - SDRETURN
+23 ; List of Clinics from the HOSPITAL LOCATION (#44) file that meet the search criteria.
+24 ;
+25 KILL ^TMP("SDES2SRCHCLNBYSC",$JOB)
+26 NEW CLINLIST
+27 SET CLINLIST=$NAME(^TMP("SDES2SRCHCLNBYSC",$JOB,"CLINLIST"))
KILL @CLINLIST
+28 SET SDRETURN=$NAME(^TMP("SDES2SRCHCLNBYSC",$JOB,"JSON"))
KILL @SDRETURN
+29 ;
+30 NEW SDERRORS
+31 SET SDSEARCH("SDDATETIME")=DT
+32 ;
+33 DO VALCONTEXT^SDES2VALCONTEXT(.SDERRORS,.SDCONTEXT)
+34 IF $DATA(SDERRORS)
Begin DoDot:1
+35 SET SDERRORS("ClinicAudit",1)=""
MERGE @CLINLIST=SDERRORS
+36 DO ENCODE^XLFJSON(.CLINLIST,.SDRETURN)
KILL @CLINLIST,CLINLIST,SDSEARCH("SDDATETIME")
End DoDot:1
QUIT
+37 ;
+38 DO VALSRCHFLDS(.SDERRORS,.SDSEARCH)
+39 IF $DATA(SDERRORS)
Begin DoDot:1
+40 SET SDERRORS("ClinicAudit",1)=""
MERGE @CLINLIST=SDERRORS
+41 DO ENCODE^XLFJSON(.CLINLIST,.SDRETURN)
KILL @CLINLIST,CLINLIST,SDSEARCH("SDDATETIME")
End DoDot:1
QUIT
+42 ;
+43 DO GETCLINICLIST(.CLINLIST,.SDSEARCH)
+44 DO ENCODE^XLFJSON(.CLINLIST,.SDRETURN)
+45 KILL @CLINLIST,CLINLIST,SDSEARCH("SDDATETIME")
+46 QUIT
+47 ;
VALSRCHFLDS(SDERRORS,SDSEARCH) ; validate incoming search parameters
+1 ; Input - SDERRORS = passed in by reference, represents the errors that could be generated when validating the search string
+2 ; STATION = Station Number for Division
+3 ; STARTING STOP CODE = Stop Code to search against or beginning of a Stop Code range, if ENDING STOP CODE is defined
+4 ; ENDING STOP CODE = The last Stop Code in a range to search against
+5 NEW SDSTATION,STOPCDSTART,STOPCDEND
+6 ;
+7 SET SDSTATION=$GET(SDSEARCH("STATION"))
+8 IF SDSTATION'=""
DO VALSTATIONNUM^SDES2VAL4(.SDERRORS,SDSTATION,DT)
+9 if $DATA(SDERRORS)
QUIT
+10 ;
+11 SET STOPCDSTART=$GET(SDSEARCH("STARTING STOP CODE"))
+12 SET STOPCDEND=$GET(SDSEARCH("ENDING STOP CODE"))
+13 IF $LENGTH(STOPCDSTART)
IF '$DATA(^DIC(40.7,"C",STOPCDSTART))
DO ERRLOG^SDESJSON(.SDERRORS,270)
QUIT
+14 IF $LENGTH(STOPCDEND)
IF '$DATA(^DIC(40.7,"C",STOPCDEND))
DO ERRLOG^SDESJSON(.SDERRORS,270)
QUIT
+15 ;
+16 IF STOPCDSTART=""&(STOPCDEND'="")
DO ERRLOG^SDESJSON(.SDERRORS,578)
QUIT
+17 IF SDSTATION=""&(STOPCDSTART="")
DO ERRLOG^SDESJSON(.SDERRORS,577)
QUIT
+18 IF STOPCDSTART'=""&(STOPCDEND'="")&(STOPCDSTART>STOPCDEND)
DO ERRLOG^SDESJSON(.SDERRORS,579)
QUIT
+19 ;
+20 QUIT
+21 ;
GETCLINICLIST(CLINLIST,SDSEARCH) ; pull matching clinics using the first input parameter passed in by the RPC
+1 ; Input -
+2 ; SDSEARCH = Search array values, including Station Number and/or Stop Code (Stop Code range)
+3 ; CLINLIST = passed in by reference; represents the temp global that will be returned as output
+4 ; Output - CLINLIST = Temp global with list of clinic names and clinic IENs.
+5 NEW CLNIEN,SDCLINCNT,SDDATETIME,STOPCODESTART,STOPCODEEND,SDSTATION
+6 SET STOPCODESTART=$GET(SDSEARCH("STARTING STOP CODE"))
+7 SET STOPCODEEND=$GET(SDSEARCH("ENDING STOP CODE"))
+8 SET SDSTATION=$GET(SDSEARCH("STATION"))
+9 SET SDDATETIME=$GET(SDSEARCH("SDDATETIME"))
+10 ;
+11 IF $LENGTH(STOPCODESTART)
IF '$LENGTH(STOPCODEEND)
SET STOPCODEEND=STOPCODESTART
+12 ;
+13 SET (CLNIEN,SDCLINCNT)=0
+14 FOR
SET CLNIEN=$ORDER(^SC(CLNIEN))
if 'CLNIEN
QUIT
IF $DATA(^SC(CLNIEN,0))
Begin DoDot:1
+15 IF $LENGTH(SDSTATION)
if $$WRONGDIVISION(CLNIEN,SDSTATION)
QUIT
+16 if $$INACTIVE^SDES2UTIL(CLNIEN,SDDATETIME)
QUIT
+17 IF $LENGTH(STOPCODESTART)
if $$WRONGSTOPCODE(CLNIEN,STOPCODESTART,STOPCODEEND)
QUIT
+18 SET SDCLINCNT=SDCLINCNT+1
+19 DO BUILDRETURN(CLNIEN,SDCLINCNT,.CLINLIST,.SDDATETIME)
End DoDot:1
+20 IF SDCLINCNT=0
SET @CLINLIST@("ClinicAudit",1)=""
+21 QUIT
+22 ;
BUILDRETURN(SDCLINICIEN,SDCLINCNT,CLINLIST,SDDATETIME) ;Build return array with clinic data
+1 ; input - SDCLINICIEN = IEN of clinic in #44
+2 ; CLINLIST = passed by reference, represents the temp global of clinics and associated data that will be returned
+3 ; output - CLINLIST = clinic temp global and their associated data to be sent back to the client
+4 ;
+5 NEW SDFIELDS,SDDATA,SDPRVCNT,SDCLINPROVIDER,SDPROVIDERID,SDPROVIDERNAME,SDDEFAULTPROV,SDPROVIDERSECID
+6 NEW SDSICNT,SDSPECINIEN,SDSPECINSTRUCT
+7 SET SDFIELDS=".01;3.5;8;10;16;20;21;60;61;62;99;99.1;1912;1918;2002;2502;2503;2508;2509;2510;2511"
+8 DO GETS^DIQ(44,SDCLINICIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
+9 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"ClinicIEN")=SDCLINICIEN
+10 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DivisionName")=$GET(SDDATA(44,SDCLINICIEN_",",3.5,"E"))
+11 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"ClinicName")=$GET(SDDATA(44,SDCLINICIEN_",",.01,"E"))
+12 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"PatientFriendlyName")=$GET(SDDATA(44,SDCLINICIEN_",",60,"E"))
+13 ; initialize default provider fields to null to ensure they are always defined (in the event no default provider is found)
+14 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderActive")=""
+15 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderIEN")=""
+16 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderName")=""
+17 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderSecID")=""
+18 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"StopCodeIEN")=$GET(SDDATA(44,SDCLINICIEN_",",8,"I"))
+19 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"StopCodeName")=$GET(SDDATA(44,SDCLINICIEN_",",8,"E"))
+20 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"StopCodeAMIS")=$$GET1^DIQ(40.7,$GET(SDDATA(44,SDCLINICIEN_",",8,"I")),1,"I")
+21 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"CreditStopCodeIEN")=$GET(SDDATA(44,SDCLINICIEN_",",2503,"I"))
+22 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"CreditStopCodeName")=$GET(SDDATA(44,SDCLINICIEN_",",2503,"E"))
+23 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"CreditStopCodeAMIS")=$$GET1^DIQ(40.7,$GET(SDDATA(44,SDCLINICIEN_",",2503,"I")),1,"I")
+24 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"NonCountClinic")=$GET(SDDATA(44,SDCLINICIEN_",",2502,"E"))
+25 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"ECheckIn")=$GET(SDDATA(44,SDCLINICIEN_",",20,"E"))
+26 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"PreCheckIn")=$GET(SDDATA(44,SDCLINICIEN_",",21,"E"))
+27 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"PhysicalLocation")=$GET(SDDATA(44,SDCLINICIEN_",",10,"E"))
+28 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DirectScheduling")=$GET(SDDATA(44,SDCLINICIEN_",",61,"E"))
+29 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DisplayApptToPats")=$GET(SDDATA(44,SDCLINICIEN_",",62,"E"))
+30 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"Telephone")=$$TELEPHONE^SDES2UTIL($GET(SDDATA(44,SDCLINICIEN_",",99,"E")))
+31 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"TelephoneExt")=$$EXT^SDES2UTIL($GET(SDDATA(44,SDCLINICIEN_",",99.1,"E")))
+32 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"ApptLength")=$GET(SDDATA(44,SDCLINICIEN_",",1912,"E"))
+33 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"OverbooksPerDay")=$GET(SDDATA(44,SDCLINICIEN_",",1918,"E"))
+34 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"MaxDaysForFuture")=$GET(SDDATA(44,SDCLINICIEN_",",2002,"E"))
+35 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"NoShowLetter")=$GET(SDDATA(44,SDCLINICIEN_",",2508,"E"))
+36 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"PreApptLetter")=$GET(SDDATA(44,SDCLINICIEN_",",2509,"E"))
+37 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"ClinicCancelLetter")=$GET(SDDATA(44,SDCLINICIEN_",",2510,"E"))
+38 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"ApptCancelLetter")=$GET(SDDATA(44,SDCLINICIEN_",",2511,"E"))
+39 ;
+40 SET SDSICNT=0
+41 SET SDSPECINIEN=0
FOR
SET SDSPECINIEN=$ORDER(^SC(SDCLINICIEN,"SI",SDSPECINIEN))
if 'SDSPECINIEN
QUIT
Begin DoDot:1
+42 SET SDSPECINSTRUCT=$$GET1^DIQ(44.03,SDSPECINIEN_","_SDCLINICIEN_",",.01,"E")
+43 SET SDSICNT=SDSICNT+1
+44 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"SpecialInstructions",SDSICNT,"InstructionText")=SDSPECINSTRUCT
End DoDot:1
+45 ; set empty object if no records are found
+46 IF '$DATA(@CLINLIST@("ClinicAudit",SDCLINCNT,"SpecialInstructions"))
SET @CLINLIST@("ClinicAudit",SDCLINCNT,"SpecialInstructions",1)=""
+47 ;
+48 SET SDPRVCNT=0
+49 SET SDCLINPROVIDER=0
FOR
SET SDCLINPROVIDER=$ORDER(^SC(SDCLINICIEN,"PR",SDCLINPROVIDER))
if 'SDCLINPROVIDER
QUIT
Begin DoDot:1
+50 SET SDPROVIDERID=$$GET1^DIQ(44.1,SDCLINPROVIDER_","_SDCLINICIEN_",",.01,"I")
+51 SET SDPROVIDERNAME=$$GET1^DIQ(200,SDPROVIDERID,.01,"E")
+52 SET SDPROVIDERSECID=$$GET1^DIQ(200,SDPROVIDERID,205.1,"I")
+53 SET SDDEFAULTPROV=$$GET1^DIQ(44.1,SDCLINPROVIDER_","_SDCLINICIEN_",",.02,"I")
+54 IF SDDEFAULTPROV
Begin DoDot:2
+55 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderIEN")=SDPROVIDERID
+56 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderName")=$$GET1^DIQ(200,SDPROVIDERID,.01,"E")
+57 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderSecID")=SDPROVIDERSECID
+58 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"DefaultProviderActive")=$$ACTIVPRV^PXAPI(SDPROVIDERID,$GET(SDDATETIME))
End DoDot:2
QUIT
+59 SET SDPRVCNT=SDPRVCNT+1
+60 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",SDPRVCNT,"Name")=SDPROVIDERNAME
+61 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",SDPRVCNT,"ID")=SDPROVIDERID
+62 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",SDPRVCNT,"SecID")=SDPROVIDERSECID
+63 SET @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",SDPRVCNT,"Active")=$$ACTIVPRV^PXAPI(SDPROVIDERID,$GET(SDDATETIME))
End DoDot:1
+64 ; set empty object if no records are found
+65 IF '$DATA(@CLINLIST@("ClinicAudit",SDCLINCNT,"Providers"))
SET @CLINLIST@("ClinicAudit",SDCLINCNT,"Providers",1)=""
+66 QUIT
+67 ;
WRONGDIVISION(SDCLINICIEN,STATION) ;
+1 ; Screen out Clinics that don't match passed in Station Number
+2 NEW SDDIVISION,FACNUM
+3 SET SDDIVISION=$$GET1^DIQ(44,SDCLINICIEN,3.5,"I")
+4 SET FACNUM=$$GET1^DIQ(40.8,SDDIVISION,1,"I")
+5 IF FACNUM'=STATION
QUIT 1
+6 QUIT 0
+7 ;
WRONGSTOPCODE(SDCLINICIEN,STOPCODESTART,STOPCODEEND) ;
+1 ; Screen out Clinics that don't match the passed in Stop Codes
+2 NEW STOPCDIEN,STOPCODE
+3 SET STOPCDIEN=$$GET1^DIQ(44,SDCLINICIEN,8,"I")
+4 SET STOPCODE=$$GET1^DIQ(40.7,STOPCDIEN,1,"I")
+5 IF STOPCODE<STOPCODESTART!(STOPCODE>STOPCODEEND)
QUIT 1
+6 QUIT 0
+7 ;