source: ccr/trunk/p/C0COVREL.m@ 1731

Last change on this file since 1731 was 1586, checked in by Sam Habiel, 12 years ago

Changed license to AGPL. Some clean-up for XINDEX

File size: 4.5 KB
Line 
1C0COVREL ; CCDCCR/ELN - CCR/CCD PROCESSING FOR LAB,RAD,TIU RESULTS ; 10/12/15
2 ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
3 ; (C) ELN 2012
4 ;
5 ; This program is free software: you can redistribute it and/or modify
6 ; it under the terms of the GNU Affero General Public License as
7 ; published by the Free Software Foundation, either version 3 of the
8 ; License, or (at your option) any later version.
9 ;
10 ; This program is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU Affero General Public License for more details.
14 ;
15 ; You should have received a copy of the GNU Affero General Public License
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
17 ;
18LIST ; LIST THE HL7 MESSAGE; ALSO, EXTRACT THE RESULT VARIABLES TO C0CLB
19 N C0CI,C0CJ,C0COBT,C0CHB,C0CVAR,C0CLB2,C0CLB,C0CLI,C0CLOBX,C0CTAB,C0CTYP
20 I '$D(C0CLB) S C0CLB=$NA(^TMP("C0CCCR",$J,"RESULTS")) ; BASE GLB FOR LABS VARS
21 I '$D(C0CQT) S C0CQT=0
22 I '$D(DFN) S DFN=1 ; DEFAULT TEST PATIENT
23 I '$D(^TMP("C0CCCR","LABTBL",0)) D SETTBL^C0COVREU ;INITIALIZE LAB TABLE
24 I ^TMP("C0CCCR","LABTBL",0)'="V3" D SETTBL^C0COVREU ;NEED NEWEST VERSION
25 I '$D(^TMP("HLS",$J,1)) D GHL7^C0COVREU ; GET HL7 MGS IF NOT ALREADY DONE
26 S C0CTAB=$NA(^TMP("C0CCCR","LABTBL")) ; BASE OF OBX TABLE
27 S C0CHB=$NA(^TMP("HLS",$J))
28 S C0CI=""
29 S @C0CLB@(0)=0 ; INITALIZE RESULTS VARS COUNT
30 F S C0CI=$O(@C0CHB@(C0CI)) Q:C0CI="" D ; FOR ALL RECORDS IN HL7 MSG
31 . K C0CVAR,XV,C0CX1,C0CX2 ; CLEAR OUT VARIABLE VALUES
32 . S C0CTYP=$P(@C0CHB@(C0CI),"|",1)
33 . D LTYP^C0COVREU(@C0CHB@(C0CI),C0CTYP,.C0CVAR,C0CQT)
34 . M XV=C0CVAR ;
35 . I C0CTYP="OBR" D ; BEGINNING OF NEW SECTION
36 . . S @C0CLB@(0)=@C0CLB@(0)+1 ; INCREMENT COUNT
37 . . S C0CLI=@C0CLB@(0) ; INDEX FOR THIS RESULT
38 . . ;M @C0CLB@(C0CLI)=C0CVAR ; PERSIST THE OBR VARS
39 . . S XV("RESULTOBJECTID")="RESULT_"_C0CLI
40 . . S C0CX1=XV("RESULTSOURCEACTORID") ; SOURCE FROM OBR
41 . . S XV("RESULTSOURCEACTORID")="ACTORPROVIDER_"_$P($P(C0CX1,"^",1),"-",1)
42 . . S C0CX1=XV("RESULTASSESSMENTDATETIME") ;DATE TIME IN HL7 FORMAT
43 . . S C0CX2=$$HL7TFM^XLFDT(C0CX1,"L") ;FM DT LOCAL
44 . . S XV("RESULTASSESSMENTDATETIME")=$$FMDTOUTC^C0CUTIL(C0CX2,"DT") ;UTC TIME
45 . . M @C0CLB@(C0CLI)=XV ; PERSIST THE OBR VARS
46 . . S C0CLOBX=0 ; MARK THE BEGINNING OF A NEW SECTION
47 . I C0CTYP="OBX" D ; SPECIAL CASE FOR OBX
48 . . ; RESULTTESTCODEVALUE AND RESULTTESTDESCRIPTIONTEXT
49 . . I C0CVAR("C3")="LN" D ; PRIMARY CODE IS LOINC
50 . . . S XV("RESULTTESTCODEVALUE")=C0CVAR("C1") ; THE LOINC CODE VALUE
51 . . . S XV("RESULTTESTCODINGSYSTEM")="LOINC" ; DISPLAY NAME FOR LOINC
52 . . . S XV("RESULTTESTDESCRIPTIONTEXT")=C0CVAR("C2") ; DESCRIPTION TEXT
53 . . E I C0CVAR("C6")="LN" D ; SECONDARY CODE IS LOINC
54 . . . S XV("RESULTTESTCODEVALUE")=C0CVAR("C4") ; THE LOINC CODE VALUE
55 . . . S XV("RESULTTESTCODINGSYSTEM")="LOINC" ; DISPLAY NAME FOR LOINC
56 . . . S XV("RESULTTESTDESCRIPTIONTEXT")=C0CVAR("C5") ; DESCRIPTION TEXT
57 . . E I C0CVAR("C6")'="" D ; NO LOINC CODES, USE SECONDARY IF PRESENT
58 . . . S XV("RESULTTESTCODEVALUE")=C0CVAR("C4") ; SECONDARY CODE VALUE
59 . . . S XV("RESULTTESTCODINGSYSTEM")=C0CVAR("C6") ; SECONDARY CODE NAME
60 . . . S XV("RESULTTESTDESCRIPTIONTEXT")=C0CVAR("C5") ; SECONDARY TEXT
61 . . E D ; NO SECONDARY, USE PRIMARY
62 . . . S XV("RESULTTESTCODEVALUE")=C0CVAR("C1") ; PRIMARY CODE VALUE
63 . . . S XV("RESULTTESTCODINGSYSTEM")=C0CVAR("C3") ; PRIMARY DISPLAY NAME
64 . . . S XV("RESULTTESTDESCRIPTIONTEXT")=C0CVAR("C2") ; USE PRIMARY TEXT
65 . . N C0CZG S C0CZG=XV("RESULTTESTNORMALDESCTEXT") ;
66 . . S XV("RESULTTESTNORMALDESCTEXT")=C0CZG
67 . . S C0CZG=XV("RESULTTESTVALUE")
68 . . S XV("RESULTTESTVALUE")=C0CZG
69 . I C0CTYP="OBX" D ; PROCESS TEST RESULTS
70 . . I C0CLOBX=0 D ; FIRST TEST RESULT FOR THIS SECTION
71 . . . S C0CLB2=$NA(@C0CLB@(C0CLI,"M","TEST")) ; INDENT FOR TEST RESULTS
72 . . S C0CLOBX=C0CLOBX+1 ; INCREMENT TEST COUNT
73 . . S @C0CLB2@(0)=C0CLOBX ; STORE THE TEST COUNT
74 . . S XV("RESULTTESTOBJECTID")="RESULTTEST_"_C0CLI_"_"_C0CLOBX
75 . . S C0CX1=XV("RESULTTESTSOURCEACTORID") ; TEST SOURCE
76 . . S C0CX2=$P($P(C0CX1,"^",1),"-",1) ; PULL OUT STATION NUMBER
77 . . S XV("RESULTTESTSOURCEACTORID")="ACTORORGANIZATION_"_C0CX2
78 . . S XV("RESULTTESTNORMALSOURCEACTORID")=XV("RESULTTESTSOURCEACTORID")
79 . . S C0CX1=XV("RESULTTESTDATETIME") ;DATE TIME IN HL7 FORMAT
80 . . S C0CX2=$$HL7TFM^XLFDT(C0CX1,"L") ;FM DT LOCAL
81 . . S XV("RESULTTESTDATETIME")=$$FMDTOUTC^C0CUTIL(C0CX2,"DT") ;UTC TIME
82 . . M @C0CLB2@(C0CLOBX)=XV ; PERSIST THE TEST RESULT VARIABLES
83 . I 'C0CQT D ;
84 . . W C0CI," ",C0CTYP,!
85 Q
Note: See TracBrowser for help on using the repository browser.