source: FOIAVistA/trunk/r/FUNCTIONAL_INDEPENDENCE-RMIM/RMIMHL.m@ 1535

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

initial load of FOIAVistA 6/30/08 version

File size: 4.1 KB
Line 
1RMIMHL ;WPB/JLTP ; FIM HL7 UTILITY ; 20-SEPT-2002
2 ;;1.0;FUNCTIONAL INDEPENDENCE;;Apr 15, 2003
3SND(X) ; Generate HL7 Message for Austin
4 N ADMDT,CS,DA,DCDT,DIE,DME,DR,FS,HL,HLA,HLI,I,IDX,IFN,RC,RES,RM,T,TYPES
5 S IFN=+$G(X)
6 D INIT^HLFNC2("RMIM DRIVER",.HL) I $G(HL) Q -1
7 S FS=HL("FS"),CS=$E(HL("ECH")),RC=$E(HL("ECH"),2)
8 F I=0:1:8 S RM(I)=$G(^RMIM(783,IFN,I))
9 S HLA("HLS",1)=$$PID,HLA("HLS",2)=$$PV1,HLA("HLS",3)=$$NTE
10 S HLA("HLS",4)=$$OBR,HLA("HLS",5)=$$OBXDG,IDX=5
11 S TYPES="ADMISSION^DISCHARGE^INTERIM^FOLLOW-UP^GOALS" F T=1:1:5 D
12 .Q:RM(T+3)?."^" S IDX=IDX+1,HLA("HLS",IDX)=$$OBXS(T)
13 ;S (I,HLI)=0 F S I=$O(^RMIM(783,IFN,100,I)) Q:'I S X=^(I,0) D
14 ;.S HLI=HLI+1,IDX=IDX+1,HLA("HLS",IDX)=$$OBXN(X)
15 S X=$G(^RMIM(783,IFN,0)),ADMDT=$P(X,U,10),DCDT=$P(X,U,11),DFN=$P(X,U,3)
16 S X=DFN_U_ADMDT_U_DCDT
17 I DCDT]"",ADMDT]"" D DME^RMIMRP(.DME,X) D
18 .S I=0 F S I=$O(DME(I)) Q:'I D
19 ..S DME="OBX"_FS_I_FS_"TX"_FS_"DME ITEMS"_FS_FS_DME(I)
20 ..S $P(DME,FS,12)="F"
21 ..S IDX=IDX+1,HLA("HLS",IDX)=DME
22 D GENERATE^HLMA("RMIM DRIVER","LM",1,.RES)
23 S DIE="^RMIM(783,",DA=IFN,DR=".13///T" D ^DIE
24 Q RES
25PID() ; Build and Return the PID Segment
26 N ADDR,CASE,CITY,DFN,DOB,MARRIED,PHONE,PID,PNM,RACE,SEX
27 N SSN,STATE,STREET,ZIP
28 S PID=""
29 S SSN=$P(RM(0),U,4),$P(PID,FS,2)=SSN,$P(PID,FS,19)=SSN
30 S DFN=$P(RM(0),U,3),$P(PID,FS,3)=DFN
31 S PNM=$$HLNAME^HLFNC($P(^DPT(DFN,0),U)),$P(PID,FS,5)=PNM
32 S DOB=$$HLDATE^HLFNC($P(RM(0),U,5)),$P(PID,FS,7)=DOB
33 S CASE=$P(RM(0),U,2),$P(PID,FS,4)=IFN_CS_CASE
34 S STREET=$P(RM(1),U,1)
35 S CITY=$P(RM(1),U,2)
36 S STATE=$P(RM(1),U,3)
37 S ZIP=$P(RM(1),U,4)
38 ;S ADDR=$$HLADDR^HLFNC(STREET,CITY_U_STATE_U_ZIP),$P(PID,FS,11)=ADDR
39 S ADDR=STREET_U_U_CITY_U_STATE_U_ZIP_U_"USA",$P(PID,FS,11)=ADDR
40 S PHONE=$$HLPHONE^HLFNC($P(RM(1),U,5)),$P(PID,FS,13)=PHONE
41 S SEX=$P(RM(1),U,6),$P(PID,FS,8)=SEX
42 S RACE=$P(RM(1),U,7),$P(PID,FS,10)=RACE
43 S MARRIED=$P(RM(1),U,8),$P(PID,FS,16)=MARRIED
44 S MIL=$P(RM(1),U,9),$P(PID,FS,27)=MIL
45 Q "PID"_FS_PID
46OBR() ; KEY FIELDS
47 N ADMIT,ASSDT,CARE,DOB,ETIOL,FAC,IMPAIR,OBR,ONSET,SSN,UNIV
48 S OBR="",UNIV=""
49 S SSN=$P(RM(0),U,4),$P(UNIV,CS)=SSN
50 S DOB=$$HLDATE^HLFNC($P(RM(0),U,5)),$P(UNIV,CS,2)=DOB
51 S CARE=$P(RM(0),U,7),$P(UNIV,CS,3)=$$CCV(CARE)
52 S ONSET=$$HLDATE^HLFNC($P(RM(0),U,9)),$P(UNIV,CS,4)=ONSET
53 S IMPAIR=$P(RM(0),U,8),$P(UNIV,CS,5)=IMPAIR
54 S ADMIT=$$HLDATE^HLFNC($P(RM(0),U,10)),$P(UNIV,CS,6)=ADMIT
55 S FAC=$P(RM(0),U,6)
56 I $L(FAC)<4 S FAC=FAC_" "
57 I $L(FAC)<4 S FAC=FAC_" "
58 S $P(UNIV,CS,7)=FAC
59 S $P(OBR,FS,4)=UNIV
60 S ETIOL=$P(RM(2),U,10),$P(OBR,FS,13)=ETIOL
61 S ASSDT=$$HLDATE^HLFNC($P(RM(0),U,12)),$P(OBR,FS,7)=ASSDT
62 Q "OBR"_FS_OBR
63PV1() ; EPISODE OF CARE DATA
64 N ADMCL,ADMDT,CARECL,DCDT,PV1
65 S PV1=""
66 S ADMCL=$P(RM(2),U),$P(PV1,FS,4)=ADMCL
67 S CARECL=$P(RM(0),U,7),$P(PV1,FS,2)=$$CCV(CARECL)
68 S ADMDT=$$HLDATE^HLFNC($P(RM(0),U,10)),$P(PV1,FS,44)=ADMDT
69 S DCDT=$$HLDATE^HLFNC($P(RM(0),U,11)),$P(PV1,FS,45)=DCDT
70 Q "PV1"_FS_PV1
71CCV(X) ; CARE CLASS CONVERSION
72 Q $S(X=1:10,X=2:"04",X=3:"09",1:X)
73NTE() ; TRANSFERS
74 N COM S COM=""
75 S COM=$P(RM(2),U,4,9)
76 F RM=1:1:6 S $P(COM,U,RM)=$$HLDATE^HLFNC($P(COM,U,RM))
77 S COM=$TR(COM,U,CS)
78 Q "NTE"_FS_"1"_FS_"L"_FS_COM
79OBXDG() ; DIAGNOSIS CODES
80 N ASIA,ICD,OBX
81 S ASIA=$P(RM(2),U,11),ICD=$TR(RM(3),U,CS)
82 S OBX="1"_FS_"CE"_FS_"DIAGNOSIS CODES"_FS_ASIA_CS_ICD
83 S $P(OBX,FS,11)="F"
84 Q "OBX"_FS_OBX
85OBXS(T) ; FIM SCORES
86 N OBX,SCORES,TYPE
87 S TYPE=$P(TYPES,U,T),OBX="",SCORES=$TR(RM(T+3),U,CS),$P(OBX,FS,5)=SCORES
88 S $P(OBX,FS,1)=IDX-5,$P(OBX,FS,2)="NM",$P(OBX,FS,3)=TYPE
89 S $P(OBX,FS,11)="F"
90 Q "OBX"_FS_OBX
91OBXN(X) ; CASE NOTES
92 N OBX S $P(OBX,FS)=HLI,$P(OBX,FS,2)="FT",$P(OBX,FS,3)="CASE NOTES"
93 S $P(OBX,FS,11)="F",$P(OBX,FS,5)=X
94 Q "OBX"_FS_OBX
95TASK ; NIGHTLY JOB
96 I '$$FIND1^DIC(4.2,"","X","Q-FIM.MED.VA.GOV","B") D Q
97 .N TX,XMDUN,XMDUZ,XMSUB,XMTEXT,XMY,XMZ
98 .S TX(1,0)="The domain Q-FIM.MED.VA.GOV does not exist in your DOMAIN "
99 .S TX(2,0)="file."
100 .S TX(3,0)="Ask your IRM to install patch XM*DBA*150."
101 .S TX(4,0)="You will not be able to transmit data to FSOD until this"
102 .S TX(5,0)="patch has been installed."
103 .S (XMDUN,XMDUZ)="FSOD TRANSMISSION",XMSUB="Missing Domain"
104 .S XMTEXT="TX(",XMY("G.RMIM FSOD")="" D ^XMD
105 S IFN=0 F S IFN=$O(^RMIM(783,"ATRAN",1,IFN)) Q:'IFN D
106 .Q:'$D(^RMIM(783,IFN,0))
107 .S STAT=$$SND(IFN)
108 Q
Note: See TracBrowser for help on using the repository browser.