source: WorldVistAEHR/trunk/r/HEALTH_SUMMARY-GMTS/GMTSMCMA.m

Last change on this file was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 5.3 KB
Line 
1GMTSMCMA ; WAS/DCB\KER - Medicine 2.2 interface routine ; 02/11/2003 [11/14/03 9:12am]
2 ;;2.7;Health Summary;**4,47,49,61,62,69**;Oct 20, 1995
3 ;
4 ; External Refernces
5 ; DBIA 10064 KILL^XM
6 ; DBIA 10070 ^XMD
7 ; DBIA 1236 $$HL7^MCORMN
8 ; DBIA 3778 HL1^MCORMN
9 ; DBIA 10090 ^DIC(4,
10 ; DBIA 10000 NOW^%DTC
11 ; DBIA 10106 $$HLDATE^HLFNC
12 ; DBIA 10106 $$HLNAME^HLFNC
13 ; DBIA 10017 ^DD("DD")
14 ; DBIA 10106 $$FMDATE^HLFNC
15 ; DBIA 10106 $$FMNAME^HLFNC
16 ; DBIA 10072 REMSBMSG^XMA1C
17 ;
18HSUM(PATID,BDATE,EDATE,OCC,WH,ATYPE) ; Health Summary API
19 N ARRAY,MESSAGE,MSH,HLECH,ST,ORD,MSTR,LOOP,MSTR,SAP,SNF,RAP,RNF,MST,PCI,VID
20 N REC,LOC,QID,XDEST,WSF,MWDDC,WDC,QRL,BUILDER,LOOP,MESS1,MESS2,TMP,SUB
21 N XMDUZ,XMTEXT,XMSUB,XMY,XMZ,XMDUN,GMTSG
22 S GMTSG=0 S:$L($T(HL1^MCORMN))>1 GMTSG=1
23 S ARRAY="TMP(""HS"",$J)"
24 S XMTEXT="TMP(""HS"",$J,"
25 S MSTR="|^~\&",HLECH=$E(MSTR,2,4)
26 F LOOP=1:1:5 S ST(LOOP)=$E(MSTR,LOOP,LOOP)
27 S MESSAGE="TMP",SAP="HEALTH SUMMARY",RAP="MEDICINE",VID=2.1
28 S REC=+$O(^DIC(4,"D",DUZ(2),"")),LOC=$P($G(^DIC(4,REC,0)),U,1)
29 S (RNF,SNF)=LOC,RAP="Medicine",SAP="Health Summary",MST="HS",PCI="P"
30 S @ARRAY@(1,0)=$$MSH(MSTR,SAP,SNF,RAP,RNF,MST,PCI,VID)
31 S ATYPE=$S(ATYPE="F":"RD",ATYPE="C":"RD",1:"PG")
32 S QRL=$$CONVERT("D",BDATE)_ST(2)_$$CONVERT("D",EDATE)
33 S QFC="R",QLR=ATYPE_ST(2)_OCC,WSF=PATID,WDDC=WH
34 S @ARRAY@(2,0)=$$QRD(WSF,WDDC,QFC,QLR,QRL)
35 I +($G(GMTSG))'>0 D Q:+ARRY=0
36 . S XMSUB="Health Summary Request",XMDUN="HEALTH SUMMARY"
37 . S XMY("G.MC MESSAGING SERVER")=""
38 . S XMDUZ=".5"
39 . D ^XMD I +($G(XMZ))=0 D KILL^XM S ARRY=0 Q
40 . S MESS1=XMZ
41 . D KILL^XM
42 . S ARRY=$$HL7^MCORMN(MESS1) D:+ARRY=0 REMOVE(MESS1,+ARRY)
43 I +($G(GMTSG))>0 D Q:$G(^TMP("MCAR1",$J,1,0))=""
44 . D HL1^MCORMN(SAP,PATID,BDATE,EDATE,OCC,ATYPE)
45 K ^TMP("MCAR",$J) D:+($G(GMTSG))'>0 SLIT(ARRY)
46 ;Below the "0" input to slit is a dummy input in this case
47 D:+($G(GMTSG))>0 SLIT(0)
48 K ^TMP("MCAR1",$J) D:+($G(GMTSG))'>0 REMOVE(MESS1,ARRY)
49 Q
50SLIT(ARRY) ; Reformat Array
51 N LOOP,COUNT,BASE,MCOUNT,BUILDER
52 S BUILDER=$S(+($G(GMTSG))'>0:("^XMB(3.9,"_ARRY_",2)"),1:"^TMP(""MCAR1"",$J)")
53 S LOOP=0,(MCOUNT,COUNT)=0,SUB=1,BASE="^TMP(""MCAR"",$J)"
54 F S LOOP=$O(@BUILDER@(LOOP)) Q:LOOP="" D SLITTER
55 Q
56SLITTER ; This will slit the message in a usable form
57 N VALUE,ROY,ROUT,LINE
58 S VALUE=@BUILDER@(LOOP,0),ROY=$E(VALUE,1,3)
59 S ROUT=$S(ROY="MSH":"SMSH",ROY="PID":"SPID",ROY="OBR":"SOBR",ROY="OBX":"SOBX",ROY="MSH":"SMSH",1:"OTHER")
60 S LINE="D "_ROUT_"(VALUE)"
61 X LINE
62 Q
63SMSH(VALUE) ; Slit the message header
64 N PROC,LOOP
65 S MSTR=$E(VALUE,4,8),SUB=1
66 F LOOP=1:1:5 S ST(LOOP)=$E(MSTR,LOOP,LOOP)
67 S MCOUNT=MCOUNT+1,COUNT=1
68 S PROC=$P($P(VALUE,ST(1),3),U,1)
69 S @BASE@(MCOUNT,COUNT,1)="PROCEDURE"_U_U_PROC
70 D SETREF(MCOUNT,COUNT,"PROCEDURE")
71 Q
72SPID(VALUE) ; Slit the PID
73 S SUB=1
74 Q
75SOBR(VALUE) ; Slit the OBR
76 N TEMP,XDATE
77 S TEMP=$$CONVERTA("D",$P(VALUE,ST(1),8))
78 S XDATE=TEMP,COUNT=COUNT+1,SUB=1
79 S @BASE@(MCOUNT,COUNT,1)="DATE/TIME"_U_U_TEMP
80 D SETREF(MCOUNT,COUNT,"DATE/TIME")
81 S TEMP=$$CONVERTA("P200",$P(VALUE,ST(1),33))
82 I TEMP'="" S COUNT=COUNT+1,@BASE@(MCOUNT,COUNT,1)="PRINCIPAL RESUILT INTERPRETER"_U_U_TEMP D SETREF(MCOUNT,COUNT,"PRINCIPAL RESULT INTERPRETER") S COUNT=COUNT+1
83 S TEMP=$$CONVERTA("P200",$P(VALUE,ST(1),34))
84 I TEMP'="" S COUNT=COUNT+1,@BASE@(MCOUNT,COUNT,1)="ASSISTANT RESUILT INTERPRETER"_U_U_TEMP D SETREF(MCOUNT,COUNT,"ASSISTANT RESULT") S COUNT=COUNT+1
85 S TEMP=$$CONVERTA("P200",$P(VALUE,ST(1),35))
86 I TEMP'="" S COUNT=COUNT+1,@BASE@(MCOUNT,COUNT,1)="TECHNICIAN"_U_U_TEMP D SETREF(MCOUNT,COUNT,"TECHNICIAN") S COUNT=COUNT+1
87 Q
88SOBX(VALUE) ; Slit the OBX
89 N XDES,TEMP,FLDTYPE,UNITS,VAL
90 S COUNT=COUNT+1
91 S SUB=1,TEMP=$P(VALUE,ST(1),4),XDES=$P(TEMP,ST(2),2)
92 S TEMP=$P(TEMP,ST(2),1),FLDTYPE=$P(TEMP,ST(3),3)
93 S:FLDTYPE=+FLDTYPE XDES=XDES_";W"
94 S VAL=$$CONVERTA(FLDTYPE,$P(VALUE,ST(1),6))
95 S UNITS=$P(TEMP,ST(1),7)
96 S @BASE@(MCOUNT,COUNT,1)=XDES_U_UNITS_U_VAL
97 D SETREF(MCOUNT,COUNT,XDES)
98 Q
99OTHER(VALUE) ; Set the next sub node if the lines continue
100 N TEMP,UNITS
101 S TEMP=$P(VALUE,ST(1),1),UNITS=$P(VALUE,ST(1),2),SUB=SUB+1
102 S @BASE@(MCOUNT,COUNT,SUB)=U_U_TEMP
103 S:UNITS'="" $P(@BASE@(MCOUNT,COUNT,1),U,2)=UNITS
104 Q
105MSH(MSTR,SAP,SNF,RAP,RNF,MST,PCI,VID) ; MSH Messaging Line
106 N MSH,Y,%,%I
107 S MSH="MSH"_MSTR,$P(MSH,ST(1),3)=SAP,$P(MSH,ST(1),4)=SNF
108 D NOW^%DTC S $P(MSH,ST(1),8)=$$CONVERT("D",%)
109 S $P(MSH,ST(1),5)=RAP,$P(MSH,ST(1),6)=RNF,$P(MSH,ST(1),9)=MST
110 S $P(MSH,ST(1),10)=PCI,$P(MSH,ST(1),11)=VID
111 Q MSH
112QRD(WSF,WDDC,QFC,QLR,QRL) ; QRD Messaging Line
113 N QRD,Y,%,%I
114 S QRD="QRD"
115 D NOW^%DTC S $P(ORD,ST(1),2)=$$CONVERT("D",%)
116 S $P(QRD,ST(1),3)=QFC,$P(QRD,ST(1),4)="I"
117 S $P(QRD,ST(1),6)=$J,$P(QRD,ST(1),8)=QLR
118 S $P(QRD,ST(1),9)=WSF,$P(QRD,ST(1),11)=WDDC,$P(QRD,ST(1),12)=QRL
119 Q QRD
120CONVERT(FILETYPE,RST) ; Convert FileMan to HL7
121 N TEMP
122 S TEMP=RST
123 S:FILETYPE="D" TEMP=$$HLDATE^HLFNC(RST,"TS")
124 S:FILETYPE="P" TEMP=$$HLNAME^HLFNC(RST)
125 Q TEMP
126CONVERTA(FILETYPE,RST) ; Convert HL7 to FileMan
127 N TEMP,Y
128 S TEMP=RST
129 I FILETYPE["D" S Y=$$FMDATE^HLFNC(RST) X ^DD("DD") S TEMP=Y
130 S:(FILETYPE["P200")!(FILETYPE["P690") TEMP=$$FMNAME^HLFNC(RST)
131 Q TEMP
132REMOVE(MESS1,MESS2) ; Remove messages from the server basket
133 N LOOP,XMSER S MESS1=+($G(MESS1)),MESS2=+($G(MESS2))
134 F LOOP=MESS1,MESS2 S XMSER="S.MCHL7SERVER" S XMZ=LOOP D:LOOP'=0 REMSBMSG^XMA1C
135 D KILL^XM
136 Q
137SETREF(MCOUNT,COUNT,XDES) ; Set Count
138 S:XDES'="" @BASE@(MCOUNT,"B",XDES,COUNT)=""
139 Q
Note: See TracBrowser for help on using the repository browser.