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

SDESCREATEAPPT2.m

Go to the documentation of this file.
SDESCREATEAPPT2 ;ALB/BLB,MGD,DJS - VISTA SCHEDULING RPCS ;Oct 7, 2022
 ;;5.3;Scheduling;**814,823,826,827**;Aug 13, 1993;Build 10
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
 ; appt in file 2. Called from wrapper level SDESCRTAPPTWRAP. See SDESCRTAPPTWRAP for required inputs.
 ;
 ;
VALIDATE(ERRORS,ARY2) ; Validate
 ; patient DFN
 S ARY2("DFN")=$G(ARY2("DFN"),"")
 I ARY2("DFN")="" D ERRLOG^SDESJSON(.ERRORS,1) Q
 I ARY2("DFN")'="",'$D(^DPT(+ARY2("DFN"),0)) D ERRLOG^SDESJSON(.ERRORS,2) Q
 ;
 ; clinic IEN
 S ARY2("CLINICIEN")=$G(ARY2("CLINICIEN"),"")
 I ARY2("CLINICIEN")="" D ERRLOG^SDESJSON(.ERRORS,18) Q
 I '$D(^SC(+ARY2("CLINICIEN"),0)) D ERRLOG^SDESJSON(.ERRORS,19) Q
 I $$INACTIVE^SDEC32(+ARY2("CLINICIEN")) D ERRLOG^SDESJSON(.ERRORS,19) Q
 ;
 ; appointment Type
 S ARY2("SDAPPTYPE")=$G(ARY2("SDAPPTYPE"),"")
 S ARY2("SDAPPTNAME")=$G(ARY2("SDAPPTNAME"),"")
 I ARY2("SDAPPTYPE")="",ARY2("SDAPPTNAME")="" D ERRLOG^SDESJSON(.ERRORS,306)
 N APPTTYPIEN,IENNOTVALID,NAMENOTVALID
 S (APPTTYPIEN,IENNOTVALID,NAMENOTVALID)=0
 I ARY2("SDAPPTNAME")'="" D
 . S APPTTYPIEN=$$FIND1^DIC(409.1,"","X",ARY2("SDAPPTNAME"),"B")
 . I 'APPTTYPIEN S NAMENOTVALID=1 Q
 . I APPTTYPIEN,('$D(^SD(409.1,APPTTYPIEN,0))) S NAMENOTVALID=1
 I $L(ARY2("SDAPPTYPE")),'ARY2("SDAPPTYPE") D
 . S ARY2("SDAPPTYPE")=$O(^SD(409.1,"B",ARY2("SDAPPTYPE"),0))
 . I 'ARY2("SDAPPTYPE") S NAMENOTVALID=1
 I ARY2("SDAPPTYPE"),('$D(^SD(409.1,ARY2("SDAPPTYPE"),0))) S IENNOTVALID=1
 I IENNOTVALID,NAMENOTVALID D ERRLOG^SDESJSON(.ERRORS,61)
 I APPTTYPIEN S ARY2("SDAPPTYPE")=APPTTYPIEN
 I 'ARY2("SDAPPTYPE") D ERRLOG^SDESJSON(.ERRORS,61)
 ;
 ; appointment date/time
 S ARY2("SDAPPTSTARTDTTM")=$G(ARY2("SDAPPTSTARTDTTM"),"")
 I ARY2("SDAPPTSTARTDTTM")="" D ERRLOG^SDESJSON(.ERRORS,76) Q
 S ARY2("SDAPPTSTARTDTTM")=$$ISOTFM^SDAMUTDT(ARY2("SDAPPTSTARTDTTM"),ARY2("CLINICIEN"))
 I ARY2("SDAPPTSTARTDTTM")=-1 S ARY2("SDAPPTSTARTDTTM")="" D ERRLOG^SDESJSON(.ERRORS,77) Q
 ;I ARY2("SDAPPTSTARTDTTM")<DT D ERRLOG^SDESJSON(.ERRORS,59) Q   ;Allow Appointments made in the Past
 ;
 ; lab date/time
 S ARY2("SDLABDTTM")=$G(ARY2("SDLABDTTM"),"")
 I ARY2("SDLABDTTM")'="" S ARY2("SDLABDTTM")=$$ISOTFM^SDAMUTDT(ARY2("SDLABDTTM"),ARY2("CLINICIEN"))
 I ARY2("SDLABDTTM")=-1 S ARY2("SDLABDTTM")="" D ERRLOG^SDESJSON(.ERRORS,147) Q
 ;
 ; xray date/time
 S ARY2("SDXRAYDTTM")=$G(ARY2("SDXRAYDTTM"),"")
 I ARY2("SDXRAYDTTM")'="" S ARY2("SDXRAYDTTM")=$$ISOTFM^SDAMUTDT(ARY2("SDXRAYDTTM"),ARY2("CLINICIEN"))
 I ARY2("SDXRAYDTTM")=-1 D ERRLOG^SDESJSON(.ERRORS,145) Q
 ;
 ; ekg date/time
 S ARY2("SDEKGDTTM")=$G(ARY2("SDEKGDTTM"),"")
 I ARY2("SDEKGDTTM")'="" S ARY2("SDEKGDTTM")=$$ISOTFM^SDAMUTDT(ARY2("SDEKGDTTM"),ARY2("CLINICIEN"))
 I ARY2("SDEKGDTTM")=-1 D ERRLOG^SDESJSON(.ERRORS,146) Q
 ;
 ; purpose of visit
 S ARY2("SDPURPOSE")=$G(ARY2("SDPURPOSE"),"")
 S ARY2("SDPURPOSE")=$E(ARY2("SDPURPOSE"),1,1)
 I ARY2("SDPURPOSE")="" D ERRLOG^SDESJSON(.ERRORS,149) Q
 I "1234"'[+ARY2("SDPURPOSE") D ERRLOG^SDESJSON(.ERRORS,148) Q
 ;
 ; collateral visit
 S ARY2("SDCOLLATERAL")=$G(ARY2("SDCOLLATERAL"),"")
 S ARY2("SDCOLLATERAL")=$E(ARY2("SDCOLLATERAL"),1,1)
 I ARY2("SDCOLLATERAL")'="",("01"'[ARY2("SDCOLLATERAL")) D ERRLOG^SDESJSON(.ERRORS,150) Q
 ;
 ; scheduling request type
 S ARY2("SDSCHREQTYPE")=$G(ARY2("SDSCHREQTYPE"),"")
 S ARY2("SDSCHREQTYPE")=$E(ARY2("SDSCHREQTYPE"),1,1)
 I ARY2("SDSCHREQTYPE")="" D ERRLOG^SDESJSON(.ERRORS,151) Q
 I ("NCPWMAO"'[ARY2("SDSCHREQTYPE")) D ERRLOG^SDESJSON(.ERRORS,152) Q
 ;
 ; next available appointment indicator
 S ARY2("SDNXTAVAAPPT")=$G(ARY2("SDNXTAVAAPPT"),"")
 S ARY2("SDNXTAVAAPPT")=$E(ARY2("SDNXTAVAAPPT"),1,1)
 I ARY2("SDNXTAVAAPPT")="" D ERRLOG^SDESJSON(.ERRORS,154) Q
 I ("0123"'[ARY2("SDNXTAVAAPPT")) D ERRLOG^SDESJSON(.ERRORS,153) Q
 ;
 ; followup visit
 S ARY2("SDFOLLOWUP")=$G(ARY2("SDFOLLOWUP"),"")
 I ARY2("SDFOLLOWUP")'="",("01"'[ARY2("SDFOLLOWUP")) D ERRLOG^SDESJSON(.ERRORS,155) Q
 ;
 Q
 ;
CREATE(ARRAY2FDA,NEWIENF2,ARY2,PID) ;
 N SDECIENS
 ;
 I $D(^DPT(ARY2("DFN"),"S",ARY2("SDAPPTSTARTDTTM"),0)) D
 .D DELETECANRECORD(ARY2("DFN"),ARY2("SDAPPTSTARTDTTM"),ARY2("CLINICIEN"))
 ;
 S NEWIENF2(1)=ARY2("SDAPPTSTARTDTTM")
 S SDECIENS="+1,"_ARY2("DFN")_","
 S ARRAY2FDA(2.98,SDECIENS,".01")=ARY2("CLINICIEN")
 S ARRAY2FDA(2.98,SDECIENS,"3")=$S($G(^DPT(+$G(DFN),.1))'="":"I",1:"")
 S ARRAY2FDA(2.98,SDECIENS,"5")=ARY2("SDLABDTTM")
 S ARRAY2FDA(2.98,SDECIENS,"6")=ARY2("SDXRAYDTTM")
 S ARRAY2FDA(2.98,SDECIENS,"7")=ARY2("SDEKGDTTM")
 S ARRAY2FDA(2.98,SDECIENS,"9")=ARY2("SDPURPOSE")
 S ARRAY2FDA(2.98,SDECIENS,"9.5")=ARY2("SDAPPTYPE")
 S ARRAY2FDA(2.98,SDECIENS,"13")=ARY2("SDCOLLATERAL")
 S ARRAY2FDA(2.98,SDECIENS,"19")=DUZ
 S ARRAY2FDA(2.98,SDECIENS,"20")=$$NOW^XLFDT
 S ARRAY2FDA(2.98,SDECIENS,"25")=ARY2("SDSCHREQTYPE")
 S ARRAY2FDA(2.98,SDECIENS,"26")=ARY2("SDNXTAVAAPPT")
 S ARRAY2FDA(2.98,SDECIENS,"27")=$G(PID)
 S ARRAY2FDA(2.98,SDECIENS,"28")=ARY2("SDFOLLOWUP")
 Q
 ;
DELETECANRECORD(DFN,DATETIME,CLINICIEN) ;
 N SUBIEN,FOUND,FDA,FDAERR
 S SUBIEN=0,FOUND=0
 F  S SUBIEN=$O(^SC(CLINICIEN,"S",DATETIME,1,SUBIEN)) Q:'SUBIEN!(FOUND=1)  D
 .I $$GET1^DIQ(44.003,SUBIEN_","_DATETIME_","_CLINICIEN_",",.01,"I")=DFN D
 ..I $$GET1^DIQ(44.003,SUBIEN_","_DATETIME_","_CLINICIEN_",",310)'="CANCELLED" D
 ...S FOUND=1
 ...S FDA(2.98,DATETIME_","_DFN_",",.01)="@"
 ...D FILE^DIE(,"FDA","FDAERR") K FDA
 ;