[1428] | 1 | C0COVRES ; CCDCCR/ELN - CCR/CCD PROCESSING FOR LAB,RAD,TIU RESULTS ; 10/12/15
|
---|
[1433] | 2 | ;;1.2;C0C;;May 11, 2012;Build 47
|
---|
[1428] | 3 | ;
|
---|
| 4 | MAP(MIXML,DFN,MOXML) ;TO MAKE THIS COMPATIBLE WITH OLD CALLING FOR EXTRACT
|
---|
| 5 | ; ASSUMES THAT EXTRACT HAS BEEN RUN AND THE VARIABLES STORED IN MIVAR
|
---|
| 6 | ; MIXML,MIVAR, AND MOXML ARE PASSED BY NAME
|
---|
| 7 | ; MIXML IS THE TEMPLATE TO USE
|
---|
| 8 | ; MOXML IS THE OUTPUT XML ARRAY
|
---|
| 9 | ; DFN IS THE PATIENT RECORD NUMBER
|
---|
| 10 | N C0COXML,C0CO,C0CV,C0CIXML
|
---|
| 11 | I '$D(MIVAR) S C0CV="" ;DEFAULT
|
---|
| 12 | E S C0CV=MIVAR ;PASSED VARIABLE ARRAY
|
---|
| 13 | I '$D(MIXML) S C0CIXML="" ;DEFAULT
|
---|
| 14 | E S C0CIXML=MIXML ;PASSED INPUT XML
|
---|
| 15 | D RPCMAP(.C0COXML,DFN,C0CV,C0CIXML) ; CALL RPC TO DO THE WORK
|
---|
| 16 | I '$D(MOXML) S C0CO=$NA(^TMP("C0CCCR",$J,DFN,"RESULTS")) ;DEFAULT FOR OUTPUT
|
---|
| 17 | E S C0CO=MOXML
|
---|
| 18 | M @C0CO=C0COXML ; COPY RESULTS TO OUTPUT
|
---|
| 19 | Q
|
---|
| 20 | RPCMAP(RTN,DFN,RMIVAR,RMIXML) ; RPC ENTRY POINT FOR MAPPING RESULTS
|
---|
| 21 | ; RTN IS PASSED BY REFERENCE
|
---|
| 22 | N C0CT0,C0CT,C0CV ; CCR TEMPLATE, RESULTS SUBTEMPLATE, VARIABLES
|
---|
| 23 | N C0CRT,C0CTT ; TEST REQUEST TEMPLATE, TEST RESULT TEMPLATE
|
---|
| 24 | I '$D(DEBUG) S DEBUG=0 ; DEFAULT NO DEBUGGING
|
---|
| 25 | I RMIXML="" D ; INPUT XML NOT PASSED
|
---|
| 26 | . D LOAD^C0CCCR0("C0CT0") ; LOAD ENTIRE CCR TEMPLATE
|
---|
| 27 | . D QUERY^C0CXPATH("C0CT0","//ContinuityOfCareRecord/Body/Results","C0CT0R")
|
---|
| 28 | . S C0CT="C0CT0R" ; NAME OF EXTRACTED RESULTS TEMPLATE
|
---|
| 29 | E S C0CT=RMIXML ; WE ARE PASSED THE RESULTS PART OF THE TEMPLATE
|
---|
| 30 | I RMIVAR="" D ; LOCATION OF VARIABLES NOT PASSED
|
---|
| 31 | . S C0CV=$NA(^TMP("C0CCCR",$J,"RESULTS")) ;DEFAULT VARIABLE LOCATION
|
---|
| 32 | E S C0CV=RMIVAR ; PASSED LOCATIONS OF VARS
|
---|
| 33 | D CP^C0CXPATH(C0CT,"C0CRT") ; START MAKING TEST REQUEST TEMPLATE
|
---|
| 34 | D REPLACE^C0CXPATH("C0CRT","","//Results/Result/Test") ; DELETE TEST FROM REQ
|
---|
| 35 | D QUERY^C0CXPATH(C0CT,"//Results/Result/Test","C0CTT") ; MAKE TEST TEMPLATE
|
---|
| 36 | D EXTRACT("C0CT",DFN,) ; LAB EXTRACT
|
---|
| 37 | D EXTRACT^C0CRARPT("C0CT",DFN,) ; RAD REPORT EXTRACT
|
---|
| 38 | ;OHUM/RUT 3111221
|
---|
| 39 | ;D EXTRACT^C0CTIU("C0CT",DFN,) ; TIU EXTRACT
|
---|
| 40 | I ^TMP("C0CCCR","TIULIMIT")'="" D EXTRACT^C0CTIU("C0CT",DFN,) ; TIU EXTRACT
|
---|
| 41 | ;OHUM/RUT
|
---|
| 42 | I '$D(@C0CV@(0)) D Q ; NO VARS THERE
|
---|
| 43 | . S RTN(0)=0 ; PASS BACK NO RESULTS INDICATOR
|
---|
| 44 | ; NO RESULTS
|
---|
| 45 | I @C0CV@(0)=0 S RTN(0)=0 Q
|
---|
| 46 | S RIMVARS=$NA(^TMP("C0CRIM","VARS",DFN,"RESULTS"))
|
---|
| 47 | K @RIMVARS
|
---|
| 48 | ;M @RIMVARS=@C0CV ; UPDATE RIMVARS SO THEY STAY IN SYNCH
|
---|
| 49 | N C0CI,C0CIN,C0CJ,C0CJN,C0CJE,C0CJS,C0CMAP,C0CTMAP,C0CTMP
|
---|
| 50 | S C0CIN=@C0CV@(0) ; COUNT OF RESULTS (OBR)
|
---|
| 51 | N C0CRTMP ; AREA TO BUILD ONE RESULT REQUEST AND ALL TESTS FOR IT
|
---|
| 52 | N C0CRBASE S C0CRBASE=$NA(^TMP($J,"TESTTMP")) ;WORK AREA
|
---|
| 53 | N C0CRBLD ; BUILD LIST FOR XML - THE BUILD IS DELAYED UNTIL THE END
|
---|
| 54 | ; TO IMPROVE PERFORMANCE
|
---|
| 55 | D QUEUE^C0CXPATH("C0CRBLD","C0CRT",1,1) ;<Results>
|
---|
| 56 | F C0CI=1:1:C0CIN D ; LOOP THROUGH VARIABLES
|
---|
| 57 | . K C0CMAP,C0CTMP ;EMPTY OUT LAST BATCH OF VARIABLES
|
---|
| 58 | . S C0CRTMP=$NA(@C0CRBASE@(C0CI)) ;PARTITION OF WORK AREA FOR EACH TEST
|
---|
| 59 | . S C0CMAP=$NA(@C0CV@(C0CI)) ;MAPPING FOR TEST REQUEST GOES HERE
|
---|
| 60 | . D MAP^C0CXPATH("C0CRT",C0CMAP,C0CRTMP) ; MAP OBR DATA
|
---|
| 61 | . D QUEUE^C0CXPATH("C0CRBLD",C0CRTMP,2,@C0CRTMP@(0)-4) ;UP TO <Test>
|
---|
| 62 | . I $D(@C0CMAP@("M","TEST",0)) D ; TESTS EXIST
|
---|
| 63 | . . S C0CJN=@C0CMAP@("M","TEST",0) ; NUMBER OF TESTS
|
---|
| 64 | . . K C0CTO ; CLEAR OUTPUT VARIABLE
|
---|
| 65 | . . F C0CJ=1:1:C0CJN D ;FOR EACH TEST RESULT
|
---|
| 66 | . . . K C0CTMAP ; EMPTY MAPS FOR TEST RESULTS
|
---|
| 67 | . . . S C0CTMP=$NA(@C0CRBASE@(C0CI,C0CJ)) ;WORK AREA FOR TEST RESULTS
|
---|
| 68 | . . . S C0CTMAP=$NA(@C0CMAP@("M","TEST",C0CJ)) ;
|
---|
| 69 | . . . D XMAP^C0CTIU1("C0CTT",C0CTMAP,C0CTMP) ; MAP TO TMP
|
---|
| 70 | . . . I C0CJ=1 S C0CJS=2 E S C0CJS=1 ;FIRST TIME,SKIP THE <Test>
|
---|
| 71 | . . . I C0CJ=C0CJN S C0CJE=@C0CTMP@(0)-1 E S C0CJE=@C0CTMP@(0) ;</Test>
|
---|
| 72 | . . . S C0CJS=1 S C0CJE=@C0CTMP@(0) ; INSERT ALL OF THE TEXT XML
|
---|
| 73 | . . . D QUEUE^C0CXPATH("C0CRBLD",C0CTMP,C0CJS,C0CJE) ; ADD TO BUILD LIST
|
---|
| 74 | . D QUEUE^C0CXPATH("C0CRBLD","C0CRT",C0CRT(0)-1,C0CRT(0)-1) ;</Result>
|
---|
| 75 | D QUEUE^C0CXPATH("C0CRBLD","C0CRT",C0CRT(0),C0CRT(0)) ;</Results>
|
---|
| 76 | D BUILD^C0CTIU1("C0CRBLD","RTN") ;RENDER THE XML
|
---|
| 77 | K @C0CRBASE ; CLEAR OUT TEMPORARY STURCTURE
|
---|
| 78 | Q
|
---|
| 79 | EXTRACT(ILXML,DFN,OLXML) ; EXTRACT LABS INTO THE C0CLVAR GLOBAL
|
---|
| 80 | ; LABXML AND LABOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
|
---|
| 81 | N C0CNSSN,C0CLB ; IS THERE AN SSN FLAG
|
---|
| 82 | S C0CNSSN=0
|
---|
| 83 | S C0CLB=$NA(^TMP("C0CCCR",$J,"RESULTS")) ; BASE GLB FOR LABS VARS
|
---|
| 84 | D GHL7^C0COVREU ; GET HL7 MESSAGE FOR THIS PATIENT
|
---|
| 85 | I C0CNSSN=1 D Q ; NO SSN, CAN'T GET HL7 FOR THIS PATIENT
|
---|
| 86 | . S @C0CLB@(0)=0
|
---|
| 87 | ;K @C0CLB ; CLEAR OUT OLD VARS IF ANY
|
---|
| 88 | N QTSAV S QTSAV=$G(C0CQT) ;SAVE QUIET FLAG
|
---|
| 89 | S C0CQT=1 ; SURPRESS LISTING
|
---|
| 90 | D LIST^C0COVREL ; EXTRACT THE VARIABLES
|
---|
| 91 | S C0CQT=QTSAV ; RESET SILENT FLAG
|
---|
| 92 | K ^TMP("HLS",$J) ; KILL HL7 MESSAGE OUTPUT
|
---|
| 93 | I $D(OLXML) S @OLXML@(0)=0 ; EXTRACT DOES NOT PRODUCE XML... SEE MAP^C0CLABS
|
---|
| 94 | Q
|
---|