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

CRHDUT.m

Go to the documentation of this file.
CRHDUT ; CAIRO/CLC - GET THE PATIENT DATA ELEMENTS FOR HANDOFF LIST ;5/13/08  05:19
 ;;1.0;CRHD;****;Jan 28, 2008;Build 19
 ;=================================================================
ALG(CRHDRTN0,CRHDSTR) ; Allergies
 N CRHDTNUM
 S CRHDTRG="CRHDRTN0"
 S DFN=+CRHDSTR
 S CRHDNUM=$P(CRHDSTR,U,2)
 S CRHDHDR=$P(CRHDSTR,U,3)
 K @CRHDTRG,CRHDRTN
 N CRHDX
 S CRHDNUM=CRHDNUM+1,CRHDTNUM=CRHDNUM
 S CRHDNUM=$G(CRHDNUM)+1
 S:$G(CRHDHDR) @CRHDTRG@(CRHDNUM)="Allergies: "
 D LIST^ORQQAL(.CRHDRTN,DFN)
 S CRHDX=0
 F  S CRHDX=$O(CRHDRTN(CRHDX)) Q:'CRHDX  D
 .S @CRHDTRG@(CRHDNUM)=$G(@CRHDTRG@(CRHDNUM))_$$SPACE($G(@CRHDTRG@(CRHDNUM)),$S($G(CRHDHDR):12,1:1))_$P(CRHDRTN(CRHDX),"^",2)
 . S CRHDNUM=CRHDNUM+1
 S @CRHDTRG@(CRHDTNUM)=CRHDNUM-1
 Q
ACTMED(CRHDRTN,CRHDSTR) ;Active Medications
 ;CRHDRTN: Target array
 ;CRHDCAT: I-Inpatient Meds
 ;         O-Outpatient Meds
 ;         B-Both
 ;CRHDIV:  0 - Do not include IV
 ;         1 - include IV
 ;CRHDNUM: next number in results array
 ;CRHDHDR: include section heading
 ;CRHDDET: details, 1-include the sig, 0-exclude sig
 ;CRHDLEN: length to return in chars. Defaults to 16 chars.
 N CRHDUD,CRHDV,CRHDX2,CRHDC,CRHDMEDS,CRHDRN,DFN,CRHDCAT,CRHDI,CRHDN,CRHDP1,CRHDP2
 N CRHDIV,CRHDNUM,CRHDHDR,CRHDDET,CRHDFG,CRHDLEN,CRHDTNUM,CRHDMCTR,CRHDTX
 S DFN=+CRHDSTR
 S CRHDCAT=$P(CRHDSTR,U,2)
 I CRHDCAT="" S CRHDCAT="I"
 S CRHDIV=$P(CRHDSTR,U,3)
 S CRHDNUM=$P(CRHDSTR,U,4)
 S CRHDHDR=$P(CRHDSTR,U,5)
 S CRHDDET=$P(CRHDSTR,U,6)
 S CRHDLEN=$P(CRHDSTR,U,7)
 I 'CRHDLEN S CRHDLEN=16
 S CRHDTRG="CRHDRTN"
 K @CRHDTRG
 S CRHDMCTR=0
 S CRHDNUM=CRHDNUM+1,CRHDTNUM=CRHDNUM
 S CRHDNUM=$G(CRHDNUM)+1
 S:$G(CRHDHDR) @CRHDTRG@(CRHDNUM)="Meds: "
 I CRHDCAT="O"!('CRHDDET) D NODETAM^CRHD2(.CRHDMEDS,DFN,CRHDCAT),NDOUT S @CRHDTRG@(CRHDTNUM)=CRHDNUM-1 Q
 I CRHDDET S CRHDX=$$PSGI^CRHDAM(.CRHDMEDS,DFN) D DOUT
 S @CRHDTRG@(CRHDTNUM)=CRHDNUM-1
 Q
NDOUT ;no details output
 S CRHDP2=" S CRHDN="""""_" F  S CRHDN=$O(CRHDMEDS(CRHDI,CRHDN)) Q:'CRHDN  D AOUTPUT"
 I CRHDCAT="I" D
 .S CRHDP1="F CRHDI=""U"""
 .I CRHDIV S CRHDP1=CRHDP1_","_"""V"""
 I CRHDCAT="O" D
 .S CRHDP1="F CRHDI=""N"""_","_"""R"""
 S CRHDP1=CRHDP1_CRHDP2
 X CRHDP1
 Q
AOUTPUT ;
 S CRHDNUM=CRHDNUM+1
 ;I HDR S @TRG@(CRHDNUM)="Medications",NUM=NUM+1,HDR=0
 ;S @CRHDTRG@(CRHDNUM)=$E($G(CRHDMEDS(CRHDI,CRHDN)),1,CRHDLEN)
 S CRHDMCTR=CRHDMCTR+1,@CRHDTRG@(CRHDNUM)=CRHDMCTR_"."_$E($G(CRHDMEDS(CRHDI,CRHDN)),1,CRHDLEN)
 Q
DOUT ;
 S (CRHDX2,CRHDFG,CRHDMCTR)=0
 F  S CRHDX2=$O(CRHDMEDS(CRHDX2)) Q:'CRHDX2!(CRHDFG)  D
 .S CRHDTX=""
 .S CRHDC=$P(CRHDMEDS(CRHDX2),"^",2)
 .Q:CRHDC=""
 .I CRHDHDR S CRHDNUM=CRHDNUM+1,@CRHDTRG@(CRHDNUM)="Inpatient Meds: ",CRHDNUM=CRHDNUM+1,CRHDHDR=0
IV .I 'CRHDIV&(CRHDC["IV DOSE") S CRHDFG=1 Q
 .I CRHDDET D
 ..I (CRHDC["=UNIT DOSE=")!(CRHDC["=IV DOSE=") S @CRHDTRG@(CRHDNUM)=$E(CRHDC,1,CRHDLEN)
 ..E  S CRHDMCTR=CRHDMCTR+1,@CRHDTRG@(CRHDNUM)=CRHDMCTR_"."_$E(CRHDC,1,CRHDLEN)
 .I 'CRHDDET S @CRHDTRG@(CRHDNUM)=$E(CRHDC,1,CRHDLEN)
 .S CRHDNUM=CRHDNUM+1
 Q
CONSULT(CRHDRTN,CRHDSTR) ;consults orders - call from cprs
 ;DFN,FILTERS,GROUPS,DTFROM,DTTHRU,EVENT
 N CRHDY,CRHDILST,ORYD,CRHDLST,X,D1,CRHDATE,CRHDGRP
 N CRHDLEN,CHRDHDR,CRHDSTS,CRHDILST,DFN
 S DFN=+CRHDSTR
 S CRHDSTS=$P(CRHDSTR,U,2)
 S CRHDNUM=$P(CRHDSTR,U,3)
 S CRHDHDR=$P(CRHDSTR,U,4)
 S CRHDLEN=$P(CRHDSTR,U,5)
 I 'CRHDLEN S CRHDLEN=20
 S CRHDTRG="CRHDRTN"
 K @CRHDTRG
 S CRHDGRP=$O(^ORD(100.98,"B","CONSULTS",0))
 ;D AGET^ORWORR(.CRHDY,DFN,"2^0",11,0,0,"")
 D AGET^ORWORR(.CRHDY,DFN,"2^0",CRHDGRP,0,0,"")
 M CRHDILST=@CRHDY
 K CRHDILST(.1)
 D DETORD("CRHDRTN",.CRHDLST,.CRHDILST,"",CRHDLEN)
 Q
IMAGING(CRHDRTN,CRHDSTR) ;Radiology orders - call from cprs
 ;DFN,FILTERS,CRHDGRPS,DTFROM,DTTHRU,EVENT
 N CRHDY,CRHDILST,ORYD,CRHDLST,X,CRHDLEN
 N D1,CRHDATE,DFN,CRHDSTS,CRHDNUM,CRHDHDR,CRHDTRG,CRHDGRP
 S DFN=+CRHDSTR
 S CRHDSTS=$P(CRHDSTR,U,2)
 S CRHDNUM=$P(CRHDSTR,U,3)
 S CRHDHDR=$P(CRHDSTR,U,4)
 S CRHDLEN=$P(CRHDSTR,U,5)
 I 'CRHDLEN S CRHDLEN=20
 S CRHDTRG="CRHDRTN"
 K @CRHDTRG
 S CRHDGRP=$O(^ORD(100.98,"B","IMAGING",0))
 ;D AGET^ORWORR(.CRHDY,DFN,"2^0",34,0,0,"")
 D AGET^ORWORR(.CRHDY,DFN,"2^0",CRHDGRP,0,0,"")
 M CRHDILST=@CRHDY
 K CRHDILST(.1)
 D DETORD(.CRHDTRG,.CRHDLST,.CRHDILST,"",CRHDLEN)
 Q
LABS(CRHDRTN,CRHDSTR) ;LABS orders - call from cprs
 ;DFN,FILTERS,CRHDGRPS,DTFROM,DTTHRU,EVENT
 N CRHDY,CRHDILST,ORYD,CRHDLST,X,D1,CRHDATE
 N DFN,CRHDSTS,CRHDNUM,CRHDHDR,CRHDLEN,CRHDTRG
 S DFN=+CRHDSTR
 S CRHDSTS=$P(CRHDSTR,U,2)
 S CRHDNUM=$P(CRHDSTR,U,3)
 S CRHDHDR=$P(CRHDSTR,U,4)
 S CRHDLEN=$P(CRHDSTR,U,5)
 I 'CRHDLEN S CRHDLEN=20
 S CRHDTRG="CRHDRTN"
 K @CRHDTRG
 S CRHDGRP=$O(^ORD(100.98,"B","LABORATORY",0))
 ;D AGET^ORWORR(.CRHDY,DFN,"2^0",5,0,0,"")
 D AGET^ORWORR(.CRHDY,DFN,"2^0",CRHDGRP,0,0,"")
 M CRHDILST=@CRHDY
 K CRHDILST(.1)
 D DETORD(.CRHDTRG,.CRHDLST,.CRHDILST,"",CRHDLEN)
 Q
PROC(CRHDRTN,CRHDSTR) ;,DFN,CRHDSTS,CRHDNUM,CRHDHDR) ;Procedures orders - call from cprs
 ;DFN,FILTERS,CRHDGRPS,DTFROM,DTTHRU,EVENT
 N CRHDY,CRHDILST,ORYD,CRHDLST,X,D1,CRHDATE
 N DFN,CRHDSTS,CRHDNUM,CRHDHDR,CRHDGRP,CRHDLEN,CRHDTRG
 S DFN=+CRHDSTR
 S CRHDSTS=$P(CRHDSTR,U,2)
 S CRHDNUM=$P(CRHDSTR,U,3)
 S CRHDHDR=$P(CRHDSTR,U,4)
 S CRHDLEN=$P(CRHDSTR,U,5)
 I 'CRHDLEN S CRHDLEN=20
 S CRHDTRG="CRHDRTN"
 K @CRHDTRG
 S CRHDGRP=$O(^ORD(100.98,"B","PROCEDURES",0))
 ;D AGET^ORWORR(.CRHDY,DFN,"2^0",43,0,0,"")
 D AGET^ORWORR(.CRHDY,DFN,"2^0",CRHDGRP,0,0,"")
 M CRHDILST=@CRHDY
 K CRHDILST(.1)
 D DETORD(.CRHDTRG,.CRHDLST,.CRHDILST,"",CRHDLEN)
 Q
DETORD(CRHDTRG,CRHDRLST,CRHDILST,CRHDHEAD,CRHDLEN) ;
 N ORYD,CRHDSTS,CRHDD1,CRHDATE,CRHDX
 S ORYD=""
 D GET4LST^ORWORR(.CRHDRLST,.CRHDILST)
 S:$G(CRHDHDR) @CRHDTRG@(CRHDNUM,0)=CRHDHEAD_": "
 S CRHDX=""
 F  S CRHDX=$O(CRHDLST(CRHDX)) Q:'CRHDX  D
 . S CRHDD1=$P(CRHDLST(CRHDX),"^",3)
 . I $E(CRHDLST(CRHDX),1)="~" D
 . .S CRHDD1=$P(CRHDLST(CRHDX),"^",3)
 . .S CRHDSTS=$P(CRHDLST(CRHDX),"^",10)
 . .S CRHDATE=$$FMTE^XLFDT(CRHDD1,2)
 . .S @CRHDTRG@(CRHDNUM)=$G(@CRHDTRG@(CRHDNUM))_$$SPACE($G(@CRHDTRG@(CRHDNUM)),$S($G(CRHDHDR):16,1:1))_$P(CRHDATE,"@",1)
 . I $E(CRHDLST(CRHDX),1)="t" D
 . .S @CRHDTRG@(CRHDNUM)=$G(@CRHDTRG@(CRHDNUM))_$$SPACE($G(@CRHDTRG@(CRHDNUM)),$S($G(CRHDHDR):16,1:1))_" "_$E(CRHDLST(CRHDX),2,$L(CRHDLST(CRHDX)))_" ("_$P($G(^ORD(100.01,+CRHDSTS,0)),"^",1)_")"
 . .S @CRHDTRG@(CRHDNUM)=$E(@CRHDTRG@(CRHDNUM),1,CRHDLEN),CRHDNUM=CRHDNUM+1
 Q
PROB(CRHDRTNA,CRHDSTR) ;DFN,NUM,CRHDHDR) ;
 ;Target array ^TMP("CRHD_PROB_DATA",$J)
 N CRHDRTN,X,DFN,CRHDNUM,CRHDHDR,CRHDTRG
 S DFN=+CRHDSTR
 S CRHDNUM=$P(CRHDSTR,U,2)
 S CRHDHDR=$P(CRHDSTR,U,3)
 S CRHDTRG="^TMP(""CRHD_PROB_DATA"",$J)"
 K @CRHDTRG
 S CRHDNUM=$G(CRHDNUM)+1
 S:$G(CRHDHDR) @CRHDTRG@(CRHDNUM,0)="Problem List: "
 D LIST^ORQQPL(.CRHDRTN,DFN,"A")
 S CRHDX=0
 F  S CRHDX=$O(CRHDRTN(CRHDX)) Q:'CRHDX  D
 . S @CRHDTRG@(CRHDNUM)=$G(@CRHDTRG@(CRHDNUM))_$$SPACE($G(@CRHDTRG@(CRHDNUM)),$S($G(CRHDHDR):15,1:1))_$P(CRHDRTN(X),"^",2)
 . S CRHDNUM=CRHDNUM+1
 ;S @CRHDTRG@(CRHDNUM)=""
 Q
RECNTLAB(CRHDROOT,DFN,CRHDNUM,CRHDHDR) ;
 ;(CRHDY,DFN,CRHDATE1,DIR,FORMAT)
 D INTERIMG^ORWLRR(.CRHDY,DFN,$$DT^XLFDT_".2359",1,"")
 Q
SPACE(CRHDX1,CRHDX) ;
 N CRHDY,CRHDY1
 S CRHDY1="",CRHDY=CRHDX-$L(CRHDX1)
 S $P(CRHDY1," ",CRHDY)=""
 Q CRHDY1
PARAM(CRHDW,CRHDX) ;
 Q $$GET^XPAR(CRHDW,CRHDX,1,"I")
 ;
PTSTS(DFN) ;Display current patient status
 N CRHDGPMV,NOW,NOWI,X,Y,%,%H,%I,CRHDA,E,CRHDDGX,VAIP,VAX,VAZ,VAZ2
 D NOW^%DTC S (VAX("DAT"),NOW)=%,NOWI=9999999.999999-%
 D LAST^VADPT3
 S CRHDGPMV(1)=$S($D(VAIP("E")):VAIP("E"),1:E) ;use ifn of last mvt from VADPT cal
 S CRHDDGX=$G(^DGPM(+CRHDGPMV(1),0)),CRHDGPMV(2)=$P(CRHDDGX,"^",2),CRHDGPMV(4)=$P(CRHDDGX,"^",18)
 S CRHDA=$S("^3^5^"[("^"_+CRHDGPMV(2)_"^"):0,1:+CRHDGPMV(2))
 Q $S('CRHDA:"IN",1:"")_"ACTIVE "_$S("^4^5^"[("^"_+CRHDGPMV(2)_"^"):"LODGER",1:"INPATIENT")
DNRPARM(CRHDNRTT,DUZ,CRHDDIV) ;GET DNR TITLES
 N CRHDPAR,CRHDSRV,CRHDTEAM
 S CRHDTEAM=$$GET^XPAR("USR.`"_DUZ,"ORLP DEFAULT TEAM",1,"I")
 S CRHDSRV=$$GET1^DIQ(200,DUZ_",",29,"E")
 S CRHDPAR="USR.`"_DUZ
 D GETLST^XPAR(.CRHDNRTT,CRHDPAR,"CRHD DNR ORDER TITLE")
 I ('CRHDNRTT)&($G(CRHDTEAM)>0) S CRHDPAR="OTL.`"_+CRHDTEAM D GETLST^XPAR(.CRHDNRTT,CRHDPAR,"CRHD DNR ORDER TITLE")
 I ('CRHDNRTT)&($G(CRHDSRV)'="") S CRHDPAR="SRV."_CRHDSRV D GETLST^XPAR(.CRHDNRTT,CRHDPAR,"CRHD DNR ORDER TITLE")
 I '+$G(CRHDDIV) S CRHDDIV=+$$SITE^VASITE
 I 'CRHDNRTT S CRHDPAR="DIV.`"_+CRHDDIV  D GETLST^XPAR(.CRHDNRTT,CRHDPAR,"CRHD DNR ORDER TITLE")
 Q