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

SDES2ARCLOSE.m

Go to the documentation of this file.
SDES2ARCLOSE  ;ALB/ANU,BLB,LAB - SDES2 DISPOSITION APPT REQ; MAR 18, 2024
 ;;5.3;Scheduling;**866,873,875**;Aug 13, 1993;Build 25
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ;
 ;
 Q
 ; INPUT
 ;
 ; 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.
 ; SDINPUT("REQUEST ID") = IEN, Pointer to SDEC APPT REQUEST file.
 ; SDINPUT("DISP") = Disposition.
 ; SDINPUT("DISPDT") = Date Dispositioned in external form (e.g.,CCYY-MM-DD)
 ; SDINPUT("PCMT") = (optional) patient-entered comments from VAOS
 ;
DISPOSITION(JSON,SDCONTEXT,SDINPUT) ; Disposition an Appointment Request
 N ERRORS,SDRETURN,ARIEN,DISP,DISPBY,DISPDT,PCMT,PARAMETERS
 ;
 ; Validate SDCONTEXT
 ;
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 I $D(ERRORS) S ERRORS("ApptReqDisposition",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
 ; Validate PARAMS
 S PARAMETERS=$$VALPARAMS(.SDINPUT,.ERRORS)
 I $D(ERRORS) S ERRORS("ApptReqDisposition",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
 ;
 S DISPBY=$S(+$G(SDCONTEXT("USER DUZ")):+SDCONTEXT("USER DUZ"),1:$G(DUZ))
 S ARIEN=$P(PARAMETERS,"^"),DISP=$P(PARAMETERS,"^",2),DISPDT=$P(PARAMETERS,"^",3),PCMT=$P(PARAMETERS,"^",4)
 D DISP(.SDRETURN,ARIEN,DISP,DISPBY,DISPDT,PCMT,SDCONTEXT("ACHERON AUDIT ID"))
 ;
 I '$D(SDRETURN) S SDRETURN("ApptReqDisposition",1)=""
 D BUILDJSON^SDES2JSON(.JSON,.SDRETURN)
 Q
 ;
VALPARAMS(PARAMS,SDERRORS) ; Validate
 N ARIEN,DISP,DISPBY,DISPDT,PCMT
 ;
 ; Validate Request ID
 S ARIEN=$G(PARAMS("REQUEST ID"))
 I $G(ARIEN)="" D ERRLOG^SDESJSON(.SDERRORS,3)
 I $G(ARIEN)'="",'$D(^SDEC(409.85,ARIEN)) D ERRLOG^SDESJSON(.SDERRORS,4)
 ;
 ; Validate Disposition
 S DISP=$G(PARAMS("DISP"))
 I $G(DISP)="" D ERRLOG^SDESJSON(.SDERRORS,42)
 ; Re-mapped the Dispositions to their corresponding pointer value
 I $G(DISP)'="" D
 .S:DISP="DEATH" DISP=1
 .S:DISP="REMOVED/NON-VA CARE" DISP=2
 .S:DISP="REMOVED/SCHEDULED-ASSIGNED" DISP=3
 .S:DISP="REMOVED/VA CONTRACT CARE" DISP=4
 .S:DISP="REMOVED/NO LONGER NECESSARY" DISP=5
 .S:DISP="ENTERED IN ERROR" DISP=6
 .S:DISP="TRANSFERRED TO EWL" DISP=7
 .S:DISP="CHANGED CLINIC" DISP=8
 .S:DISP="MRTC PARENT CLOSED" DISP=9
 .S:DISP="REMOVED/EXTERNAL APP" DISP=10 ;* 745
 .S:DISP="FAILURE TO RESPOND" DISP=11
 .S:DISP="VET SELF-CANCEL" DISP=12
 I $G(DISP)'="" D
 .I '+DISP!((DISP<1)!(DISP>12)) D
 ..D ERRLOG^SDESJSON(.SDERRORS,43)
 ;
 ; Validate DATE DISPOSITIONED
 S DISPDT=$G(PARAMS("DISPDT"))
 I $G(DISPDT)'="" S DISPDT=$$ISOTFM^SDAMUTDT(DISPDT) D
 .I DISPDT=-1 D ERRLOG^SDESJSON(.SDERRORS,55)
 I $G(DISPDT)="" D ERRLOG^SDESJSON(.SDERRORS,56)
 ;
 ; validate Patient-Entered comments
 S PCMT=$G(PARAMS("PCMT"))
 S PCMT=$TR($G(PCMT),"^"," ")
 ;
 Q:$D(SDERRORS) 0
 Q ARIEN_"^"_DISP_"^"_DISPDT_"^"_PCMT
 ;
DISP(SDRETURN,ARIEN,DISP,DISPBY,DISPDT,PCMT,AUDITID) ;Disposition an appt req
 N ARFDA,ARRET,ARMSG,X,MI,%DT,SDERR
 S SDERR=0
 S ARFDA=$NA(ARFDA(409.85,ARIEN_","))
 S @ARFDA@(19)=DISPDT
 S @ARFDA@(20)=DISPBY
 S @ARFDA@(21)=DISP
 S @ARFDA@(23)="C"
 S @ARFDA@(100)=AUDITID
 D UPDATE^DIE("","ARFDA","ARRET","ARMSG")
 I '$D(ARMSG) D
 .S SDRETURN("ApptReqDisposition","FilingSuccess")=1
 I $D(ARMSG("DIERR")) D
 .S SDERR=1
 .F MI=1:1:$G(ARMSG("DIERR")) D ERRLOG^SDESJSON(.SDRETURN,47,$G(ARMSG("DIERR",MI,"TEXT",1)))
 ;SEND HL7 TO CPRS IF RTC REQUEST
 I '$G(SDERR),$P(^SDEC(409.85,ARIEN,0),U,5)="RTC" D
 .I DISP=3!(DISP=9) D ARDISP^SDECHL7(ARIEN,"",DISPBY)
 .I DISP'=3&(DISP'=9) D ARDISP^SDECHL7(ARIEN,1,DISPBY)
 .I $D(^TMP($J,"REJECT",ARIEN)) D
 ..S SDERR=1,X=$G(^TMP(SDHL7IN("ORDER IEN")))
 ..D ERRLOG^SDESJSON(.SDRETURN,47,X)
 I '$G(SDERR) D EDITPCMT(ARIEN,PCMT)
 Q
 ;
EDITPCMT(ARIEN,COMMENTSFLD60) ; update word processing PATIENT COMMENTS (409.855,60)
 ; ARIEN - (required) IEN to entry in 409.85
 ; COMMENTSFLD60 - (optional) VAOS related patient-entered comments
 N SDFDA,PCMTSARRAY
 S COMMENTSFLD60=$G(COMMENTSFLD60)
 D WP^SDECUTL(.PCMTSARRAY,COMMENTSFLD60)
 D WP^DIE(409.85,ARIEN_",",60,"","PCMTSARRAY")
 Q
 ;