source: FOIAVistA/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJHLU.m@ 1499

Last change on this file since 1499 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.4 KB
Line 
1PSJHLU ;BIR/RLW-UTILITIES USED IN BUILDING HL7 SEGMENTS ;20 Apr 98 / 9:58 AM
2 ;;5.0; INPATIENT MEDICATIONS ;**1,56,72,102**;16 DEC 97
3 ;
4 ; Reference to ^PS(52.6 is supported by DBIA# 1231.
5 ; Reference to ^PS(52.7 is supported by DBIA# 2173.
6 ;
7INIT ; set up HL7 application variables
8 S PSJHLSDT="PS",PSJHINST=$P($$SITE^VASITE(),"^")
9 S PSJCLEAR="K FIELD F J=0:1:LIMIT S FIELD(J)="""""
10 Q
11 ;
12SEGMENT(LIMIT) ;
13 K SEGMENT
14 N SUBSEG,SEGLENGT S SUBSEG=0,SEGMENT="" F J=0:1:LIMIT D
15 .I SEGMENT']"" S SEGMENT=FIELD(J) Q
16 .S SEGMENT=SEGMENT_"|"_FIELD(J)
17 F S SEGLENGT=$L(SEGMENT) D Q:$L(SEGMENT)'>246
18 .I SEGLENGT'>246 S SEGMENT(SUBSEG)=SEGMENT
19 .I SEGLENGT>245 S SEGMENT(SUBSEG)=$E(SEGMENT,1,245),SUBSEG=SUBSEG+1 D
20 ..S SEGMENT=$E(SEGMENT,246,SEGLENGT),SEGMENT(SUBSEG)=$E(SEGMENT,1,245)
21SET S PSJI=PSJI+1,^TMP("PSJHLS",$J,PSJHLSDT,PSJI)=SEGMENT(0)
22 F J=1:1 Q:'$D(SEGMENT(J)) S ^TMP("PSJHLS",$J,PSJHLSDT,PSJI,J)=SEGMENT(J)
23 Q
24 ;
25CALL(HLEVN) ; call DHCP HL7 package -or- protocol, to pass Orders
26 ; HLEVN = number of segments in message
27 K CLERK,DDIEN,DDNUM,DOSEFORM,DOSEOR,FIELD,IVTYPE,LIMIT,NAME,NDNODE,NODE1,NODE2,PRODNAME,PROVIDER,PSGS0Y,PSJHINST,PSJHLSDT,PSJI,PSJORDER,PSOC,PSREASON,ROOMBED,SPDIEN,SEGMENT
28 I $G(PSJBCBU)=1 M PSJNAME=^TMP("PSJHLS",$J,"PS") Q
29 S PSJMSG="^TMP(""PSJHLS"",$J,""PS"")"
30 D MSG^XQOR("PS EVSEND OR",.PSJMSG)
31 Q
32 ;
33IVTYPE(PSJORDER) ; check whether a back-door order is Inpatient IV or IV fluid
34 I RXORDER["V",$P($G(@(PSJORDER_"0)")),"^",4)'="A" Q "I"
35 I RXORDER["P" I $P($G(@(PSJORDER_"0)")),"^",4)'="F" S IVTYPE="" Q IVTYPE
36 N SUB,AD,SOL,IVTYPE,NODE1 S SUB=0,IVTYPE="F"
37 ;naked reference on line below refers to the full indirect reference of PSJORDER_...
38 F TYPE="AD","SOL" S SUB=0 F S SUB=$O(@(PSJORDER_""""_TYPE_""""_","_SUB_")")) Q:(SUB="")!(IVTYPE="I") S NODE1=$G(^(SUB,0)) Q:NODE1="" D Q:IVTYPE="I"
39 .I TYPE="AD" D
40 ..I '$P($G(^PS(52.6,$P(NODE1,"^"),0)),"^",13) S IVTYPE="I"
41 .D:TYPE="SOL"
42 ..S:'$P($G(^PS(52.7,$P(NODE1,"^"),0)),"^",13) IVTYPE="I"
43 Q IVTYPE
44ENI ;Calculate Frequency for IV orders
45 N INFUSE
46 K:$L(X)<1!($L(X)>30)!(X["""")!($A(X)=45) X I '$D(X) Q
47 I X?.E1L.E S INFUSE=$$ENLU^PSGMI(X) Q:(INFUSE="TITRATE")!(INFUSE="BOLUS")
48 Q:(X="TITRATE")!(X="BOLUS")
49 I X["=" D Q ; NOIS LOU-0501-42191
50 .N X2,X1 S X1=$P(X,"="),X2=$P(X,"=",2)
51 .I X1["ML/HR",(+X1=$P(X1,"ML/HR"))!(+X1=$P(X1," ML/HR")) D
52 ..S X1=$TR(X1,"ML/HR","ml/hr")
53 .I X2["ML/HR",(+X2=$P(X2,"ML/HR"))!(+X2=$P(X2," ML/HR")) D
54 ..S X2=$TR(X2,"ML/HR","ml/hr")
55 .I X1[" ml/hr",(+X1=$P(X1," ml/hr")) D
56 ..S X1=$P(X1," ml/hr")_$P(X1," ml/hr",2,9999)
57 .I X2[" ml/hr",(+X2=$P(X2," ml/hr")) D
58 ..S X2=$P(X2," ml/hr")_$P(X2," ml/hr",2,9999)
59 .I X1["ml/hr",(+X1=$P(X1,"ml/hr")) D
60 ..S X1=$P(X1,"ml/hr")_$P(X1,"ml/hr",2,9999)
61 .I X2["ml/hr",(+X2=$P(X2,"ml/hr")) D
62 ..S X2=$P(X2,"ml/hr")_$P(X2,"ml/hr",2,9999)
63 .I X2'=+X2 D
64 ..I ($P(X2,"@",2,999)'=+$P(X2,"@",2,999)!(+$P(X2,"@",2,999)<0)) K X Q
65 .I X1=+X1 S X1=X1_" ml/hr"
66 .I X2=+X2 S X2=X2_" ml/hr"
67 .S:$P(X2,"@")=+X2 $P(X2,"@")=$P(X2,"@")_" ml/hr"
68 .S X=X1_"="_X2
69 I X'=+X,($P(X,"@",2,999)'=+$P(X,"@",2,999)!(+$P(X,"@",2,999)<0)),($P(X," ml/hr")'=+$P(X," ml/hr")!(+$P(X," ml/hr")<0)) K X Q
70 I X=+X S X=X_" ml/hr" D SPSOL S FREQ=$S('X:0,1:SPSOL\X*60+(SPSOL#X/X*60+.5)\1) K SPSOL Q
71 I X[" ml/hr" D SPSOL S FREQ=$S('X:0,1:SPSOL\X*60+(SPSOL#X/X*60+.5)\1) K SPSOL Q
72 S SPSOL=$P(X,"@",2) S:$P(X,"@")=+X $P(X,"@")=$P(X,"@")_" ml/hr" S FREQ=$S('SPSOL:0,1:1440/SPSOL\1) K SPSOL
73 Q
74SPSOL S SPSOL=+TVOLUME Q
Note: See TracBrowser for help on using the repository browser.