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

FHWDIS.m

Go to the documentation of this file.
  1. FHWDIS ; HISC/REL - Close out on discharge ;10/10/00 14:55
  1. ;;5.5;DIETETICS;;Jan 28, 2005
  1. ; Updated for outpatient meals FHDFN/DFN
  1. S FHZ115="P"_DFN D CHECK^FHOMDPA I FHDFN="" Q
  1. D NOW^%DTC S FHNOW=%,FHA0=$G(^FHPT(FHDFN,"A",ADM,0)),FHWF=$S($D(^ORD(101)):1,1:0) Q:FHA0="" Q:$P(FHA0,"^",14)
  1. S $P(^FHPT(FHDFN,"A",ADM,0),"^",14)=FHNOW
  1. S FHWRD=$P(FHA0,"^",8),FHRMB=$P(FHA0,"^",9) I FHWRD K ^FHPT("AW",FHWRD,FHDFN) S $P(^FHPT(FHDFN,"A",ADM,0),"^",8,9)="^"
  1. S EVT="L^D^^"_FHWRD_"~"_FHRMB D ^FHORX
  1. ; Close out Additional Orders
  1. F FHDR=0:0 S FHDR=$O(^FHPT("AOO",FHDFN,ADM,FHDR)) Q:FHDR<1 D AOO
  1. ; Close out Consults
  1. F FHDR=0:0 S FHDR=$O(^FHPT(FHDFN,"A",ADM,"DR",FHDR)) Q:FHDR<1 S Y=^(FHDR,0) D CON
  1. ; Close out standing orders
  1. F FHDR=0:0 S FHDR=$O(^FHPT(FHDFN,"A",ADM,"SP",FHDR)) Q:FHDR<1 S Y=^(FHDR,0) D SP
  1. ; Cancel tubefeeding
  1. S K=$P(FHA0,"^",4) I K D TF
  1. ; Cancel future early/late trays
  1. F FHDR=FHNOW:0 S FHDR=$O(^FHPT(FHDFN,"A",ADM,"EL",FHDR)) Q:FHDR<1 D EL
  1. ; Cancel supplemental feeding
  1. S K=$P(FHA0,"^",7) I K D SF
  1. ; Cancel isolation/precaution
  1. S K=$P(FHA0,"^",10) I K D IS
  1. ; Cancel diet/ place on no order
  1. D DO
  1. I $D(^DPT(DFN,.1)) D WRD^FHWADM
  1. ; Delete Diet related Food Restrictions
  1. F FHFP=0:0 S FHFP=$O(^FHPT(FHDFN,"P",FHFP)) Q:FHFP<1 S FHFP1=$G(^(FHFP,0)) I $P(FHFP1,"^",4)="Y" D FP
  1. KIL K %,%H,%I,%Y,EDT,A1,FHDR,K,FILL,FHNOW,FHO,FHA0,FHFP,FHFP1,FHORD,FHORN,FHPV,FHRMB,FHWRD,FHX,VAL,WKD,X,Y Q
  1. AOO Q:$P(^FHPT(FHDFN,"A",ADM,"OO",FHDR,0),"^",5)="X"
  1. S $P(^FHPT(FHDFN,"A",ADM,"OO",FHDR,0),"^",5,7)="X^"_FHNOW_"^"_DUZ
  1. K ^FHPT("AOO",FHDFN,ADM,FHDR)
  1. S FHORN=$P(^FHPT(FHDFN,"A",ADM,"OO",FHDR,0),"^",8) Q:'FHORN
  1. Q:'$D(^OR(100,+FHORN))
  1. S FILL="A"_";"_ADM-";"_FHDR_$P(^FHPT(FHDFN,"A",ADM,"OO",FHDR,0),"^",3)
  1. D SEND
  1. Q
  1. CON Q:$P(Y,"^",8)'="A" S $P(^FHPT(FHDFN,"A",ADM,"DR",FHDR,0),"^",8,11)="X^"_FHNOW_"^"_DUZ_"^"
  1. S K=$P(Y,"^",5)
  1. K:K ^FHPT("ADRU",K,FHDFN,ADM,FHDR) Q
  1. SP Q:$P(Y,"^",6) S $P(^FHPT(FHDFN,"A",ADM,"SP",FHDR,0),"^",6,7)=FHNOW_"^"_DUZ
  1. K ^FHPT("ASP",FHDFN,ADM,FHDR) Q
  1. TF S $P(^FHPT(FHDFN,"A",ADM,0),"^",4)="" K ^FHPT("ADTF",FHDFN,ADM)
  1. S $P(^FHPT(FHDFN,"A",ADM,"TF",K,0),"^",11,12)=FHNOW_"^"_DUZ
  1. S FHX=$G(^FHPT(FHDFN,"A",ADM,"TF",K,0))
  1. S FHORN=$P(FHX,"^",14) Q:'FHORN
  1. Q:'$D(^OR(100,+FHORN))
  1. S FILL="T"_";"_ADM_";"_K_";"_$P(FHX,"^",6)_";"_$P(FHX,"^",7)_";"_$P(FHX,"^",5)_";"
  1. D SEND
  1. Q
  1. EL S FHORN=$P(^FHPT(FHDFN,"A",ADM,"EL",FHDR,0),"^",7)
  1. I FHORN D EL1
  1. K ^FHPT(FHDFN,"A",ADM,"EL",FHDR),^FHPT("ADLT",FHDR,FHDFN,ADM)
  1. S %=$P($G(^FHPT(FHDFN,"A",ADM,"EL",0)),"^",4)-1 S:%'<0 $P(^(0),"^",4)=% Q
  1. EL1 S EDT=FHDR,WKD="" D WKD^FHWOR31
  1. S FHX=$G(^FHPT(FHDFN,"A",ADM,"EL",FHDR,0))
  1. Q:'$D(^OR(100,+FHORN))
  1. S FILL="E"_";"_ADM_";;"_FHDR_";"_FHDR_";"_WKD_";"_$P(FHX,"^",2)_";"_$P(FHX,"^",3)_";"_$P(FHX,"^",4)
  1. D SEND Q
  1. SF S $P(^FHPT(FHDFN,"A",ADM,0),"^",7)=""
  1. S $P(^FHPT(FHDFN,"A",ADM,"SF",K,0),"^",32,33)=FHNOW_"^"_DUZ Q
  1. IS S $P(^FHPT(FHDFN,"A",ADM,0),"^",10)="" K ^FHPT("AIS",FHDFN,ADM)
  1. S FHORN=$P(FHA0,"^",13) Q:'FHORN
  1. Q:'$D(^OR(100,+FHORN))
  1. S FILL="I"_";"_ADM_";"_K D SEND
  1. Q
  1. DO F A1=FHNOW:0 S A1=$O(^FHPT(FHDFN,"A",ADM,"AC",A1)) Q:A1="" K ^FHPT(FHDFN,"A",ADM,"AC",A1)
  1. F FHDR=0:0 S FHDR=$O(^FHPT(FHDFN,"A",ADM,"DI",FHDR)) Q:FHDR<1 D D1
  1. S FHA0=$P(FHA0,"^",2) Q:'FHA0 S FHA0=$P($G(^FHPT(FHDFN,"A",ADM,"DI",FHA0,0)),"^",7) Q:FHA0="X"
  1. D ORD^FHORD7 S ^FHPT(FHDFN,"A",ADM,"DI",FHORD,0)=FHORD_"^^^^^^X^^"_FHNOW_"^^"_DUZ_"^"_FHNOW
  1. S ^FHPT(FHDFN,"A",ADM,"AC",FHNOW,0)=FHNOW_"^"_FHORD
  1. S $P(^FHPT(FHDFN,"A",ADM,0),"^",2,3)=FHORD_"^" Q
  1. D1 ; Get all filler fields for Diet
  1. S FHORN=$P($G(^FHPT(FHDFN,"A",ADM,"DI",FHDR,0)),"^",14,15)
  1. I +FHORN>0,$P(FHORN,"^",2)>2 S FHORN=+FHORN,$P(^FHPT(FHDFN,"A",ADM,"DI",FHDR,0),"^",15)=1 D D2
  1. Q
  1. D2 S FHX=$G(^FHPT(FHDFN,"A",ADM,"DI",FHDR,0))
  1. Q:$P(FHX,"^",7)="P"!($P(FHX,"^",7)="X")
  1. S FHO=$P(FHX,"^",2,6),VAL="" D VAL^FHWORP(FHO,.VAL) Q:VAL=""
  1. Q:'$D(^OR(100,+FHORN))
  1. S FILL=$S($P(FHX,"^",7)="N":"N",1:"D")_";"_ADM_";"_FHDR_";"_$P(FHX,"^",9)_";"_$P(FHX,"^",10)_";"_$P(FHX,"^",7)_";"_$G(^FHPT(FHDFN,"A",ADM,"DI",FHDR,1))_";"_$P(FHX,"^",8)_";;"_VAL
  1. D SEND Q
  1. FP K ^FHPT(FHDFN,"P",FHFP,0),^FHPT(FHDFN,"P","B",+FHFP1,FHFP)
  1. S %=$P($G(^FHPT(FHDFN,"P",0)),"^",4)-1 S:%'<0 $P(^(0),"^",4)=% Q
  1. SEND ; Send MSG to OE/RR
  1. D CODE D:$D(MSG) MSG^XQOR("FH EVSEND OR",.MSG) Q
  1. CODE ; Code Cancel For Discharge
  1. K MSG S ACT="OC" D SITE^FH
  1. ; code MSH
  1. S MSG(1)="MSH|^~\&|DIETETICS|"_SITE(1)_"|||||ORM"
  1. ; code PID
  1. S MSG(2)="PID|||"_DFN_"||"_$P($G(^DPT(DFN,0)),"^",1)
  1. ; code ORC
  1. S DATE=$$FMTHL7^XLFDT(FHNOW),FHPV=DUZ
  1. S MSG(3)="ORC|"_ACT_"|"_FHORN_"^OR|"_FILL_"^FH|||||||||"_FHPV_"|||"_DATE_"|Dietetics Canceled Order."
  1. K %,ACT,DATE,FILL,SITE Q