| 1 | C0COVREU        ; CCDCCR/ELN - CCR/CCD PROCESSING FOR LAB,RAD,TIU RESULTS ; 10/12/15
 | 
|---|
| 2 |                ;;1.2;C0C;;May 11, 2012;Build 47
 | 
|---|
| 3 |                ;
 | 
|---|
| 4 |                ;
 | 
|---|
| 5 | GHL7       ; GET HL7 MESSAGE FOR LABS FOR THIS PATIENT
 | 
|---|
| 6 |                N C0CPTID,C0CSPC,C0CSDT,C0CEDT,C0CR,C0CLLMT,C0CLSTRT
 | 
|---|
| 7 |                ; SET UP FOR LAB API CALL
 | 
|---|
| 8 |                S C0CPTID=$$SSN^C0CDPT(DFN) ; GET THE SSN FOR THIS PATIENT
 | 
|---|
| 9 |                I C0CPTID="" D  Q  ; NO SSN, COMPLAIN AND QUIT
 | 
|---|
| 10 |                . W "LAB LOOKUP FAILED, NO SSN",!
 | 
|---|
| 11 |                . S C0CNSSN=1 ; SET NO SSN FLAG
 | 
|---|
| 12 |                S C0CSPC="*" ; LOOKING FOR ALL LABS
 | 
|---|
| 13 |                ;I $D(^TMP("C0CCCR","RPMS")) D  ; RUNNING RPMS
 | 
|---|
| 14 |                ;. D DT^DILF(,"T-365",.C0CSDT) ; START DATE ONE YEAR AGO TO LIMIT VOLUME
 | 
|---|
| 15 |                ;E  D DT^DILF(,"T-5000",.C0CSDT) ; START DATE LONG AGO TO GET EVERYTHING
 | 
|---|
| 16 |                ;D DT^DILF(,"T",.C0CEDT) ; END DATE TODAY
 | 
|---|
| 17 |                S C0CLLMT=$$GET^C0CPARMS("LABLIMIT") ; GET THE LIMIT PARM
 | 
|---|
| 18 |                S C0CLSTRT=$$GET^C0CPARMS("LABSTART") ; GET START PARM
 | 
|---|
| 19 |                D DT^DILF(,C0CLLMT,.C0CSDT) ;
 | 
|---|
| 20 |                W "LAB LIMIT: ",C0CLLMT,!
 | 
|---|
| 21 |                D DT^DILF(,C0CLSTRT,.C0CEDT) ; END DATE TODAY - IMPLEMENT END DATE PARM
 | 
|---|
| 22 |                S C0CR=$$LAB^C0CLA7Q(C0CPTID,C0CSDT,C0CEDT,C0CSPC,C0CSPC) ; CALL LAB LOOKUP
 | 
|---|
| 23 |                Q
 | 
|---|
| 24 | LTYP(OSEG,OTYP,OVARA,OC0CQT)       ;
 | 
|---|
| 25 |                N OI,OI2,OTAB,OTI,OV,OVAR
 | 
|---|
| 26 |                S OTAB=$NA(@C0CTAB@(OTYP)) ; TABLE FOR SEGMENT TYPE
 | 
|---|
| 27 |                I '$D(OC0CQT) S C0CQT=0 ; NOT C0CQT IS DEFAULT
 | 
|---|
| 28 |                E  S C0CQT=OC0CQT ; ACCEPT C0CQT FLAG
 | 
|---|
| 29 |                I 1 D  ; FOR HL7 SEGMENT TYPE
 | 
|---|
| 30 |                . S OI="" ; INDEX INTO FIELDS IN SEG
 | 
|---|
| 31 |                . F  S OI=$O(@OTAB@(OI)) Q:OI=""  D  ; FOR EACH FIELD OF THE SEGMENT
 | 
|---|
| 32 |                . . S OTI=$P(@OTAB@(OI),"^",1) ; TABLE INDEX
 | 
|---|
| 33 |                . . S OVAR=$P(@OTAB@(OI),"^",4) ; CCR VARIABLE IF DEFINED
 | 
|---|
| 34 |                . . S OV=$P(OSEG,"|",OTI+1) ; PULL OUT VALUE
 | 
|---|
| 35 |                . . I $P(OI,";",2)'="" D  ; THIS IS DEFINING A SUB-VALUE
 | 
|---|
| 36 |                . . . S OI2=$P(OTI,";",2) ; THE SUB-INDEX
 | 
|---|
| 37 |                . . . S OV=$P(OV,"^",OI2) ; PULL OUT SUB-VALUE
 | 
|---|
| 38 |                . . I OVAR'="" S OVARA(OVAR)=OV ; PASS BACK VARIABLE AND VALUE
 | 
|---|
| 39 |                . . I 'C0CQT D  ; PRINT OUTPUT IF C0CQT IS FALSE
 | 
|---|
| 40 |                . . . I OV'="" W OI_": "_$P(@OTAB@(OI),"^",3),": ",OVAR,": ",OV,!
 | 
|---|
| 41 |                Q
 | 
|---|
| 42 | LOBX       ;
 | 
|---|
| 43 |                Q
 | 
|---|
| 44 |                ;
 | 
|---|
| 45 | OUT(DFN)        ; WRITE OUT A CCR THAT HAS JUST BEEN PROCESSED (FOR TESTING)
 | 
|---|
| 46 |                N GA,GF,GD
 | 
|---|
| 47 |                S GA=$NA(^TMP("C0CCCR",$J,DFN,"CCR",1))
 | 
|---|
| 48 |                S GF="RPMS_CCR_"_DFN_"_"_DT_".xml"
 | 
|---|
| 49 |                S GD=^TMP("C0CCCR","ODIR")
 | 
|---|
| 50 |                W $$OUTPUT^C0CXPATH(GA,GF,GD)
 | 
|---|
| 51 |                Q
 | 
|---|
| 52 | SETTBL   ;
 | 
|---|
| 53 |                K X ; CLEAR X
 | 
|---|
| 54 |                S X("PID","PID1")="1^00104^Set ID - Patient ID"
 | 
|---|
| 55 |                S X("PID","PID2")="2^00105^Patient ID (External ID)"
 | 
|---|
| 56 |                S X("PID","PID3")="3^00106^Patient ID (Internal ID)"
 | 
|---|
| 57 |                S X("PID","PID4")="4^00107^Alternate Patient ID"
 | 
|---|
| 58 |                S X("PID","PID5")="5^00108^Patient's Name"
 | 
|---|
| 59 |                S X("PID","PID6")="6^00109^Mother's Maiden Name"
 | 
|---|
| 60 |                S X("PID","PID7")="7^00110^Date of Birth"
 | 
|---|
| 61 |                S X("PID","PID8")="8^00111^Sex"
 | 
|---|
| 62 |                S X("PID","PID9")="9^00112^Patient Alias"
 | 
|---|
| 63 |                S X("PID","PID10")="10^00113^Race"
 | 
|---|
| 64 |                S X("PID","PID11")="11^00114^Patient Address"
 | 
|---|
| 65 |                S X("PID","PID12")="12^00115^County Code"
 | 
|---|
| 66 |                S X("PID","PID13")="13^00116^Phone Number - Home"
 | 
|---|
| 67 |                S X("PID","PID14")="14^00117^Phone Number - Business"
 | 
|---|
| 68 |                S X("PID","PID15")="15^00118^Language - Patient"
 | 
|---|
| 69 |                S X("PID","PID16")="16^00119^Marital Status"
 | 
|---|
| 70 |                S X("PID","PID17")="17^00120^Religion"
 | 
|---|
| 71 |                S X("PID","PID18")="18^00121^Patient Account Number"
 | 
|---|
| 72 |                S X("PID","PID19")="19^00122^SSN Number - Patient"
 | 
|---|
| 73 |                S X("PID","PID20")="20^00123^Drivers License - Patient"
 | 
|---|
| 74 |                S X("PID","PID21")="21^00124^Mother's Identifier"
 | 
|---|
| 75 |                S X("PID","PID22")="22^00125^Ethnic Group"
 | 
|---|
| 76 |                S X("PID","PID23")="23^00126^Birth Place"
 | 
|---|
| 77 |                S X("PID","PID24")="24^00127^Multiple Birth Indicator"
 | 
|---|
| 78 |                S X("PID","PID25")="25^00128^Birth Order"
 | 
|---|
| 79 |                S X("PID","PID26")="26^00129^Citizenship"
 | 
|---|
| 80 |                S X("PID","PID27")="27^00130^Veteran.s Military Status"
 | 
|---|
| 81 |                S X("PID","PID28")="28^00739^Nationality"
 | 
|---|
| 82 |                S X("PID","PID29")="29^00740^Patient Death Date/Time"
 | 
|---|
| 83 |                S X("PID","PID30")="30^00741^Patient Death Indicator"
 | 
|---|
| 84 |                S X("NTE","NTE1")="1^00573^Set ID - NTE"
 | 
|---|
| 85 |                S X("NTE","NTE2")="2^00574^Source of Comment"
 | 
|---|
| 86 |                S X("NTE","NTE3")="3^00575^Comment"
 | 
|---|
| 87 |                S X("ORC","ORC1")="1^00215^Order Control"
 | 
|---|
| 88 |                S X("ORC","ORC2")="2^00216^Placer Order Number"
 | 
|---|
| 89 |                S X("ORC","ORC3")="3^00217^Filler Order Number"
 | 
|---|
| 90 |                S X("ORC","ORC4")="4^00218^Placer Order Number"
 | 
|---|
| 91 |                S X("ORC","ORC5")="5^00219^Order Status"
 | 
|---|
| 92 |                S X("ORC","ORC6")="6^00220^Response Flag"
 | 
|---|
| 93 |                S X("ORC","ORC7")="7^00221^Quantity/Timing"
 | 
|---|
| 94 |                S X("ORC","ORC8")="8^00222^Parent"
 | 
|---|
| 95 |                S X("ORC","ORC9")="9^00223^Date/Time of Transaction"
 | 
|---|
| 96 |                S X("ORC","ORC10")="10^00224^Entered By"
 | 
|---|
| 97 |                S X("ORC","ORC11")="11^00225^Verified By"
 | 
|---|
| 98 |                S X("ORC","ORC12")="12^00226^Ordering Provider"
 | 
|---|
| 99 |                S X("ORC","ORC13")="13^00227^Enterer's Location"
 | 
|---|
| 100 |                S X("ORC","ORC14")="14^00228^Call Back Phone Number"
 | 
|---|
| 101 |                S X("ORC","ORC15")="15^00229^Order Effective Date/Time"
 | 
|---|
| 102 |                S X("ORC","ORC16")="16^00230^Order Control Code Reason"
 | 
|---|
| 103 |                S X("ORC","ORC17")="17^00231^Entering Organization"
 | 
|---|
| 104 |                S X("ORC","ORC18")="18^00232^Entering Device"
 | 
|---|
| 105 |                S X("ORC","ORC19")="19^00233^Action By"
 | 
|---|
| 106 |                S X("OBR","OBR1")="1^00237^Set ID - Observation Request"
 | 
|---|
| 107 |                S X("OBR","OBR2")="2^00216^Placer Order Number"
 | 
|---|
| 108 |                S X("OBR","OBR3")="3^00217^Filler Order Number"
 | 
|---|
| 109 |                S X("OBR","OBR4")="4^00238^Universal Service ID"
 | 
|---|
| 110 |                S X("OBR","OBR4;LOINC")="4;1^00238^Universal Service ID - LOINC^RESULTCODE"
 | 
|---|
| 111 |                S X("OBR","OBR4;DESC")="4;2^00238^Universal Service ID - DESC^RESULTDESCRIPTIONTEXT"
 | 
|---|
| 112 |                S X("OBR","OBR4;VACODE")="4;3^00238^Universal Service ID - VACODE^RESULTCODINGSYSTEM"
 | 
|---|
| 113 |                S X("OBR","OBR5")="5^00239^Priority"
 | 
|---|
| 114 |                S X("OBR","OBR6")="6^00240^Requested Date/Time"
 | 
|---|
| 115 |                S X("OBR","OBR7")="7^00241^Observation Date/Time^RESULTASSESSMENTDATETIME"
 | 
|---|
| 116 |                S X("OBR","OBR8")="8^00242^Observation End Date/Time"
 | 
|---|
| 117 |                S X("OBR","OBR9")="9^00243^Collection Volume"
 | 
|---|
| 118 |                S X("OBR","OBR10")="10^00244^Collector Identifier"
 | 
|---|
| 119 |                S X("OBR","OBR11")="11^00245^Specimen Action Code"
 | 
|---|
| 120 |                S X("OBR","OBR12")="12^00246^Danger Code"
 | 
|---|
| 121 |                S X("OBR","OBR13")="13^00247^Relevant Clinical Info."
 | 
|---|
| 122 |                S X("OBR","OBR14")="14^00248^Specimen Rcv'd. Date/Time"
 | 
|---|
| 123 |                S X("OBR","OBR15")="15^00249^Specimen Source"
 | 
|---|
| 124 |                S X("OBR","OBR16")="16^00226^Ordering Provider XCN^RESULTSOURCEACTORID"
 | 
|---|
| 125 |                S X("OBR","OBR17")="17^00250^Order Callback Phone Number"
 | 
|---|
| 126 |                S X("OBR","OBR18")="18^00251^Placers Field 1"
 | 
|---|
| 127 |                S X("OBR","OBR19")="19^00252^Placers Field 2"
 | 
|---|
| 128 |                S X("OBR","OBR20")="20^00253^Filler Field 1"
 | 
|---|
| 129 |                S X("OBR","OBR21")="21^00254^Filler Field 2"
 | 
|---|
| 130 |                S X("OBR","OBR22")="22^00255^Results Rpt./Status Change"
 | 
|---|
| 131 |                S X("OBR","OBR23")="23^00256^Charge to Practice"
 | 
|---|
| 132 |                S X("OBR","OBR24")="24^00257^Diagnostic Service Sect"
 | 
|---|
| 133 |                S X("OBR","OBR25")="25^00258^Result Status^RESULTSTATUS"
 | 
|---|
| 134 |                S X("OBR","OBR26")="26^00259^Parent Result"
 | 
|---|
| 135 |                S X("OBR","OBR27")="27^00221^Quantity/Timing"
 | 
|---|
| 136 |                S X("OBR","OBR28")="28^00260^Result Copies to"
 | 
|---|
| 137 |                S X("OBR","OBR29")="29^00261^Parent Number"
 | 
|---|
| 138 |                S X("OBR","OBR30")="30^00262^Transportation Mode"
 | 
|---|
| 139 |                S X("OBR","OBR31")="31^00263^Reason for Study"
 | 
|---|
| 140 |                S X("OBR","OBR32")="32^00264^Principal Result Interpreter"
 | 
|---|
| 141 |                S X("OBR","OBR33")="33^00265^Assistant Result Interpreter"
 | 
|---|
| 142 |                S X("OBR","OBR34")="34^00266^Technician"
 | 
|---|
| 143 |                S X("OBR","OBR35")="35^00267^Transcriptionist"
 | 
|---|
| 144 |                S X("OBR","OBR36")="36^00268^Scheduled Date/Time"
 | 
|---|
| 145 |                S X("OBR","OBR37")="37^01028^Number of Sample Containers"
 | 
|---|
| 146 |                S X("OBR","OBR38")="38^38^01029 Transport Logistics of Collected Sample"
 | 
|---|
| 147 |                S X("OBR","OBR39")="39^01030^Collector.s Comment"
 | 
|---|
| 148 |                S X("OBR","OBR40")="40^01031^Transport Arrangement Responsibility"
 | 
|---|
| 149 |                S X("OBR","OBR41")="41^01032^Transport Arranged"
 | 
|---|
| 150 |                S X("OBR","OBR42")="42^01033^Escort Required"
 | 
|---|
| 151 |                S X("OBR","OBR43")="43^01034^Planned Patient Transport Comment"
 | 
|---|
| 152 |                S X("OBX","OBX1")="1^00559^Set ID - OBX"
 | 
|---|
| 153 |                S X("OBX","OBX2")="2^00676^Value Type"
 | 
|---|
| 154 |                S X("OBX","OBX3")="3^00560^Observation Identifier"
 | 
|---|
| 155 |                S X("OBX","OBX3;C1")="3;1^00560^Observation Identifier^C1"
 | 
|---|
| 156 |                S X("OBX","OBX3;C2")="3;2^00560^Observation Identifier^C2"
 | 
|---|
| 157 |                S X("OBX","OBX3;C3")="3;3^00560^Observation Identifier^C3"
 | 
|---|
| 158 |                S X("OBX","OBX3;C4")="3;4^00560^Observation Identifier^C4"
 | 
|---|
| 159 |                S X("OBX","OBX3;C5")="3;5^00560^Observation Identifier^C5"
 | 
|---|
| 160 |                S X("OBX","OBX3;C6")="3;6^00560^Observation Identifier^C6"
 | 
|---|
| 161 |                S X("OBX","OBX4")="4^00769^Observation Sub-Id"
 | 
|---|
| 162 |                S X("OBX","OBX5")="5^00561^Observation Results^RESULTTESTVALUE"
 | 
|---|
| 163 |                S X("OBX","OBX6")="6^00562^Units^RESULTTESTUNITS"
 | 
|---|
| 164 |                S X("OBX","OBX7")="7^00563^Reference Range^RESULTTESTNORMALDESCTEXT"
 | 
|---|
| 165 |                S X("OBX","OBX8")="8^00564^Abnormal Flags^RESULTTESTFLAG"
 | 
|---|
| 166 |                S X("OBX","OBX9")="9^00639^Probability"
 | 
|---|
| 167 |                S X("OBX","OBX10")="10^00565^Nature of Abnormal Test"
 | 
|---|
| 168 |                S X("OBX","OBX11")="11^00566^Observ. Result Status^RESULTTESTSTATUSTEXT"
 | 
|---|
| 169 |                S X("OBX","OBX12")="12^00567^Date Last Normal Value"
 | 
|---|
| 170 |                S X("OBX","OBX13")="13^00581^User Defined Access Checks"
 | 
|---|
| 171 |                S X("OBX","OBX14")="14^00582^Date/Time of Observation^RESULTTESTDATETIME"
 | 
|---|
| 172 |                S X("OBX","OBX15")="15^00583^Producer.s ID^RESULTTESTSOURCEACTORID"
 | 
|---|
| 173 |                S X("OBX","OBX16")="16^00584^Responsible Observer"
 | 
|---|
| 174 |                S X("OBX","OBX17")="17^00936^Observation Method"
 | 
|---|
| 175 |                K ^TMP("C0CCCR","LABTBL")
 | 
|---|
| 176 |                M ^TMP("C0CCCR","LABTBL")=X ; SET VALUES IN LAB TBL
 | 
|---|
| 177 |                S ^TMP("C0CCCR","LABTBL",0)="V3"
 | 
|---|
| 178 |                Q
 | 
|---|