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

ORMBLDSD.m

Go to the documentation of this file.
ORMBLDSD ; SLC/MKB - Build outgoing SCHEDULING ORM msgs ;01/09/18
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**434,475,377**;Dec 17, 1997;Build 582
 ;
 ;
 ;
ESC(STR) ;
 Q $$ESC^ORHLESC(STR)
 ;
HL7DATE(DATE) ; -- FM -> HL7 format
 Q $$FMTHL7^XLFDT(DATE)  ;**97
 ;
PTR(NAME) ; -- Returns ptr value of prompt in Dialog file
 Q $O(^ORD(101.41,"AB",$E("OR GTX "_NAME,1,63),0))
 ;
DC ;
 N OR0,ORDIALOG
 S OR0=$G(^OR(100,+IFN,0)) Q:'$L(OR0)
 S ORDIALOG=+$P(OR0,U,5) Q:'ORDIALOG
 D GETDLG1^ORCD(ORDIALOG),GETORDER^ORCD(+IFN)
 D EN("DC")
 Q
 ;
EN(CODE) ; -- Segments for new Scheduling order
 N A,ACT,DATEUPD,DAYS,ORNOW,APPTNUM,APPTINV,CLINIC,COMMENT,INC,INST,LOC,LOCSEG
 N NODE,OFFSET,ORIFN,ORDER,PREREQ,PKGREF,PTR,ROOM,RTCDATE,SEGCNT,START,TIME,VALUE
 N TEMP,WHOENTER,WHOSIGN,X0,X1,X2,X3,X8
 S ACT=$S(IFN[";":$P(IFN,";",2),1:1),DATEUPD=0
 S X0=$G(^OR(100,+IFN,0)),X3=$G(^OR(100,+IFN,3)),X8=$G(^OR(100,+IFN,8,ACT,0))
 S PKGREF=$P($G(^OR(100,+IFN,4)),U)
 S WHOSIGN=$P(X8,U,5)
 S WHOENTER=$P(X0,U,6)
 S WHOSIGN=$$WHOSIGN(X8)
 I WHOSIGN="" S WHOSIGN=WHOENTER
 ;I WHOSIGN'>0 S WHOSIGN=$P(X8,U,7)
 S WHOSIGN=WHOSIGN_U_$$GET1^DIQ(200,WHOSIGN,.01)
 S WHOENTER=WHOENTER_U_$$GET1^DIQ(200,WHOENTER,.01)
 I CODE'="DC" S ORDER=$P(ORMSG(4),"|",3) K ORMSG(4)
 S SEGCNT=$S(CODE="DC":3,1:4)
 S LOC=+$P(X0,U,10),LOCSEG=""
 I LOC>0 S LOCSEG=+LOC_":"_$$GET1^DIQ(44,LOC,.01)_U
 I $P($G(^SC(LOC,0)),U,3)="W" S LOCSEG=LOCSEG_$P($G(^DPT(+ORVP,.101)),U)
 S ORIFN=$S(IFN[";":IFN,1:IFN_";1")
 ;I PKGREF'>0,CODE="XO" D
 ;.S ORPREV=$P(X3,U,5) I ORPREV'>0 Q
 ;.S PKGREF=$P($G(^OR(100,ORPREV,4)),U)
 ;S ORMSG(SEGCNT)="ARQ|"_ORIFN_"^OR|"_PKGREF_"|||^followup^^^^|"_$S(CODE="DC":"S05",CODE="XO":"S03",1:"S01")_"||"
 S ORMSG(SEGCNT)="ARQ|"_ORIFN_"^OR|"_PKGREF_"|||^followup^^^^|"_$S(CODE="DC":"S05",1:"S01")_"||"
 S $P(ORMSG(1),"|",9)="SRM|"_ORIFN_U_$S(CODE="DC":"S05",CODE="XX":"S03",1:"S01")
 S A=$G(ORDIALOG($$PTR("CLINICALLY INDICATED DATE"),1))
 I A="T" S ORNOW=$$NOW^XLFDT() S A=$P(ORNOW,".")
 I A["+" D
 . S ORNOW=$$NOW^XLFDT()
 . S OFFSET=$$UP^XLFSTR($P(A,"+",2)) S DAYS=$S(OFFSET["W":+OFFSET*7,OFFSET["M":+OFFSET*30,1:+OFFSET)
 . S X1=$P(ORNOW,"."),X2=DAYS D C^%DTC S A=X_$S(A?1"N".E:"."_$P(ORNOW,"."),1:"")
 . ;S X1=$P(ORNOW,"."),X2=$P(A,"+",2) D C^%DTC S A=X_$S(A?1"N".E:"."_$P(ORNOW,"."),1:"")
 . S ORDIALOG($$PTR("CLINICALLY INDICATED DATE"),1)=A,DATEUPD=1
 S RTCDATE=$$HL7DATE(A)
 S START=$P(X0,U,8),TIME=$G(ORDIALOG($$PTR("YES/NO"),1))
 S ORMSG(SEGCNT)=ORMSG(SEGCNT)_$S(TIME=1:U_RTCDATE_"|T|",1:RTCDATE_U_"||")
 I +TIME=1 S ORLEAD="no later than ",ORTRAIL="",DATEUPD=1
 I +TIME=0 S ORLEAD="on or around (",ORTRAIL=")"
 S APPTNUM=$G(ORDIALOG($$PTR("APPT NUM"),1))
 S APPTINV=+$G(ORDIALOG($$PTR("SCH INTERVAL"),1))
 S ORMSG(SEGCNT)=ORMSG(SEGCNT)_$S(APPTINV>0:"Q"_APPTINV_"D",1:"")_"|"
 S ORMSG(SEGCNT)=ORMSG(SEGCNT)_APPTNUM_"|"
 S ORMSG(SEGCNT)=ORMSG(SEGCNT)_WHOSIGN_"||||"
 S ORMSG(SEGCNT)=ORMSG(SEGCNT)_WHOENTER_"||"
 S ORMSG(SEGCNT)=ORMSG(SEGCNT)_LOCSEG_"|||"
 S ORMSG(SEGCNT)=ORMSG(SEGCNT)_IFN_"|"_PKGREF_"|"
AIL ;
 S SEGCNT=SEGCNT+1
 S CLINIC=$G(ORDIALOG($$PTR("LOCATION"),1))
 S CLINIC=CLINIC_U_$$GET1^DIQ(44,CLINIC,.01)
 S ORMSG(SEGCNT)="AIL|||"_CLINIC
 S PTR=$$PTR("PRE REQ")
 ;
AIG ;
 S INST=0 F  S INST=$O(ORDIALOG(PTR,INST)) Q:INST'>0  S PREREQ(INST)=ORDIALOG(PTR,INST)
 I $D(PREREQ) D
 .S SEGCNT=SEGCNT+1,INC=0
 .S INST=0 F  S INST=$O(PREREQ(INST)) Q:INST'>0  D
 ..S INC=INC+1
 ..I INC=1 S ORMSG(SEGCNT)="AIG|"_INC_"|"_U_PREREQ(INST)_U_U_U_U_"|||||||||||" Q
 ..I INC>1 S ORMSG(SEGCNT,INC-1)="AIG|"_INC_"|"_U_PREREQ(INST)_U_U_U_U_"|||||||||||"
NXT ;
 S COMMENT=$G(ORDIALOG($$PTR("SD COMMENT"),1))
 I COMMENT'="" S SEGCNT=SEGCNT+1,ORMSG(SEGCNT)="NTE|6|P|"_$$ESC(COMMENT)
 I DATEUPD=1 S ORIFN=+ORIFN K ^OR(100,ORIFN,4.5) D RESPONSE^ORCSAVE,ORDTEXT^ORCSAVE1(ORIFN_";"_ACT)
 Q
WHOSIGN(X8) ;
 I $P(X8,U,5)>0 Q $P(X8,U,5)
 I $P(X8,U,7)>0 Q $P(X8,U,7)
 I $P(X8,U,3)>0 Q $P(X8,U,3)
 I $P(X8,U,17)>0 Q $P(X8,U,17)
 Q ""
 ;