- Timestamp:
- May 21, 2009, 1:12:11 PM (16 years ago)
- Location:
- ccr/trunk/p
- Files:
-
- 2 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/C0CACTOR.m
r415 r508 1 C0CACTOR 2 ;; 0.4;CCDCCR;nopatch;noreleasedate1 C0CACTOR ; CCDCCR/GPL - CCR/CCD PROCESSING FOR ACTORS ; 7/3/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 27 27 ; 0.4 Patient data rouine refactored; adjustments here--SMH 28 28 ; 29 EXTRACT(IPXML,ALST,AXML) 29 EXTRACT(IPXML,ALST,AXML) ; EXTRACT ACTOR FROM ALST INTO PROVIDED XML TEMPLATE 30 30 ; IPXML is the Input Actor Template into which we substitute values 31 31 ; This is straight XML. Values to be substituted are in @@VAL@@ format. … … 83 83 Q 84 84 ; 85 PATIENT(INXML,AIEN,AOID,OUTXML) 85 PATIENT(INXML,AIEN,AOID,OUTXML) ; PROCESS A PATIENT ACTOR 86 86 I DEBUG W "PROCESSING ACTOR PATIENT ",AIEN,! 87 87 N AMAP,ZX … … 142 142 Q 143 143 ; 144 SYSTEM(INXML,AIEN,AOID,OUTXML) 144 SYSTEM(INXML,AIEN,AOID,OUTXML) ; PROCESS A SYSTEM ACTOR 145 145 ; 146 146 ; N AMAP … … 154 154 Q 155 155 ; 156 NOK(INXML,AIEN,AOID,OUTXML) 156 NOK(INXML,AIEN,AOID,OUTXML) ; PROCESS A NEXT OF KIN TYPE ACTOR 157 157 ; 158 158 ; N AMAP … … 167 167 Q 168 168 ; 169 ORG(INXML,AIEN,AOID,OUTXML) 169 ORG(INXML,AIEN,AOID,OUTXML) ; PROCESS AN ORGANIZATION TYPE ACTOR 170 170 ; 171 171 ; N AMAP … … 178 178 Q 179 179 ; 180 PROVIDER(INXML,AIEN,AOID,OUTXML) 180 PROVIDER(INXML,AIEN,AOID,OUTXML) ; PROCESS A PROVIDER TYPE ACTOR 181 181 ; 182 182 ; N AMAP -
ccr/trunk/p/C0CALERT.m
r396 r508 1 C0CALERT 2 ;; 0.1;CCDCCR;;SEP 11,2008;1 C0CALERT ; CCDCCR/CKU/GPL - CCR/CCD PROCESSING FOR ALERTS ; 09/11/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota and others. 4 4 ;Licensed under the terms of the GNU General Public License. … … 22 22 Q 23 23 ; 24 EXTRACT(ALTXML,DFN,ALTOUTXML) 24 EXTRACT(ALTXML,DFN,ALTOUTXML) ; EXTRACT ALERTS INTO PROVIDED XML TEMPLATE 25 25 ; 26 26 ; ALTXML AND ALTOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED … … 118 118 S @ALTTVMAP@(0)=ALTCNT-1 ; RECORD THE NUMBER OF ALERTS 119 119 Q 120 PRSGLB(INGLB) 120 PRSGLB(INGLB) ; EXTRINSIC TO PARSE GLOBALS AND RETURN THE FILE NUMBER 121 121 ; INGLB IS OF THE FORM: PSNDF(50.6, 122 122 ; RETURN 50.6 -
ccr/trunk/p/C0CBAT.m
r441 r508 1 C0CBAT 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CBAT ; CCDCCR/GPL - CCR Batch utilities; 4/21/09 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2009 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 21 21 Q 22 22 ; 23 STOP 23 STOP ; STOP A CURRENTLY RUNNING BATCH JOB 24 24 I '$D(^TMP("C0CBAT","RUNNING")) Q ; 25 25 W !,!,"HALTING CCR BATCH",! … … 33 33 Q 34 34 ; 35 START 35 START ; STARTS A TAKSMAN CCR BATCH JOB - FOR USE IN A MENU OPTION 36 36 ; 37 37 I $D(^TMP("C0CBAT","RUNNING")) D Q ; ONLY ONE ALLOWED AT A TIME … … 48 48 Q 49 49 ; 50 EN 50 EN ; BATCH ENTRY POINT 51 51 ; PROCESSES THE SUBSCRIPTION FILE, EXTRACTING CCR VARIABLES FOR EACH 52 52 ; PATIENT WITH AN ACTIVE SUBSCRIPTION, AND IF CHECKSUMS INDICATE A CHANGE, … … 146 146 Q 147 147 ; 148 BLDHOT(ZHB) 148 BLDHOT(ZHB) ; BUILD HOT LIST AT GLOBAL ZHB, PASSED BY NAME 149 149 ; SEARCHS FOR PATIENTS IN THE "AC" INDEX OF THE ORDER FILE 150 150 N ZDFN … … 156 156 Q 157 157 ; 158 COUNT(ZB) 158 COUNT(ZB) ; EXTRINSIC THAT RETURNS THE NUMBER OF ARRAY ELEMENTS 159 159 N ZI,ZN 160 160 S ZN=0 … … 164 164 Q ZN 165 165 ; 166 UPDIEVARPTR(ZVAR,ZTYP) 166 UPDIEVARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE 167 167 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO 168 168 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO … … 186 186 Q ZVARN 187 187 ; 188 UPDIE 188 UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS 189 189 K ZERR 190 190 D CLEAN^DILF … … 197 197 Q 198 198 ; 199 SETFDA(C0CSN,C0CSV) 199 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN 200 200 ; TO SET TO VALUE C0CSV. 201 201 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE … … 207 207 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV 208 208 Q 209 ZFILE(ZFN,ZTAB) 209 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED 210 210 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN) 211 211 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 215 215 E S ZR="" 216 216 Q ZR 217 ZFIELD(ZFN,ZTAB) 217 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED 218 218 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN) 219 219 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 224 224 Q ZR 225 225 ; 226 ZVALUE(ZFN,ZTAB) 226 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED 227 227 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN) 228 228 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA -
ccr/trunk/p/C0CCCD.m
r416 r508 1 C0CCCD 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CCCD ; CCDCCR/GPL - CCD MAIN PROCESSING; 6/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 21 21 ; EXPORT A CCR 22 22 ; 23 EXPORT 23 EXPORT ; EXPORT ENTRY POINT FOR CCR 24 24 ; Select a patient. 25 25 S DIC=2,DIC(0)="AEMQ" D ^DIC … … 29 29 Q 30 30 ; 31 XPAT(DFN,DIR,FN) 31 XPAT(DFN,DIR,FN) ; EXPORT ONE PATIENT TO A FILE 32 32 ; DIR IS THE DIRECTORY, DEFAULTS IF NULL TO ^TMP("C0CCCR","ODIR") 33 33 ; FN IS FILE NAME, DEFAULTS IF NULL … … 49 49 Q 50 50 ; 51 CCDRPC(CCRGRTN,DFN,CCRPART,TIME1,TIME2,HDRARY) 51 CCDRPC(CCRGRTN,DFN,CCRPART,TIME1,TIME2,HDRARY) ;RPC ENTRY POINT FOR CCR OUTPUT 52 52 ; CCRGRTN IS RETURN ARRAY PASSED BY NAME 53 53 ; DFN IS PATIENT IEN … … 146 146 Q 147 147 ; 148 INITSTPS(TAB) 148 INITSTPS(TAB) ; INITIALIZE CCR PROCESSING STEPS 149 149 ; TAB IS PASSED BY NAME 150 150 W "TAB= ",TAB,! … … 155 155 Q 156 156 ; 157 SHAVE(SHXML) 157 SHAVE(SHXML) ; REMOVES THE 2-6 AND N-1 AND N-2 LINES FROM A COMPONENT 158 158 ; NEEDED TO EXPOSE THE REPEATING PARTS FOR GENERATION 159 159 N SHTMP,SHBLD ; TEMP ARRAY AND BUILD LIST … … 168 168 Q 169 169 ; 170 UNSHAVE(ORIGXML,SHXML) 170 UNSHAVE(ORIGXML,SHXML) ; REPLACES THE 2-6 AND N-1 AND N-2 LINES FROM TEMPLATE 171 171 ; NEEDED TO RESTORM FIXED TOP AND BOTTOM OF THE COMPONENT XML 172 172 N SHTMP,SHBLD ; TEMP ARRAY AND BUILD LIST … … 181 181 Q 182 182 ; 183 HDRMAP(CXML,DFN,IHDR) 183 HDRMAP(CXML,DFN,IHDR) ; MAP HEADER VARIABLES: FROM, TO ECT 184 184 N VMAP S VMAP=$NA(^TMP("C0CCCR",$J,DFN,"HEADER")) 185 185 ; K @VMAP … … 200 200 Q 201 201 ; 202 ACTLST(AXML,ACTRTN) 202 ACTLST(AXML,ACTRTN) ; RETURN THE ACTOR LIST FOR THE XML IN AXML 203 203 ; AXML AND ACTRTN ARE PASSED BY NAME 204 204 ; EACH ACTOR RECORD HAS 3 PARTS - IE IF OBJECTID=ACTORPATIENT_2 … … 225 225 Q 226 226 ; 227 TEST 227 TEST ; RUN ALL THE TEST CASES 228 228 D TESTALL^C0CUNIT("C0CCCR") 229 229 Q 230 230 ; 231 ZTEST(WHICH) 231 ZTEST(WHICH) ; RUN ONE SET OF TESTS 232 232 N ZTMP 233 233 D ZLOAD^C0CUNIT("ZTMP","C0CCCR") … … 235 235 Q 236 236 ; 237 TLIST 237 TLIST ; LIST THE TESTS 238 238 N ZTMP 239 239 D ZLOAD^C0CUNIT("ZTMP","C0CCCR") -
ccr/trunk/p/C0CCCD1.m
r391 r508 1 C0CCCD1 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CCCD1 ; CCDCCR/GPL - CCD TEMPLATE AND ACCESS ROUTINES; 6/7/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 23 23 Q 24 24 ; 25 ZT(ZARY,BAT,LINE) 25 ZT(ZARY,BAT,LINE) ; private routine to add a line to the ZARY array 26 26 ; ZARY IS PASSED BY NAME 27 27 ; BAT is a string identifying the section … … 38 38 Q 39 39 ; 40 ZLOAD(ZARY,ROUTINE) 40 ZLOAD(ZARY,ROUTINE) ; load tests into ZARY which is passed by reference 41 41 ; ZARY IS PASSED BY NAME 42 42 ; ZARY = name of the root, closed array format (e.g., "^TMP($J)") … … 58 58 Q 59 59 ; 60 LOAD(ARY) 60 LOAD(ARY) ; LOAD A CCR TEMPLATE INTO ARY PASSED BY NAME 61 61 D ZLOAD(ARY,"C0CCCD1") 62 62 ; ZWR @ARY 63 63 Q 64 64 ; 65 TRMCCD 66 Q 67 MARKUP 65 TRMCCD ; ROUTINE TO BE WRITTEN TO REMOVE CCR MARKUP FROM CCD 66 Q 67 MARKUP ;<MARKUP> 68 68 ;;<Body> 69 69 ;;<Problems> -
ccr/trunk/p/C0CCCR.m
r441 r508 1 C0CCCR 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CCCR ; CCDCCR/GPL - CCR MAIN PROCESSING; 6/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 21 21 ; EXPORT A CCR 22 22 ; 23 EXPORT 23 EXPORT ; EXPORT ENTRY POINT FOR CCR 24 24 ; Select a patient. 25 25 S DIC=2,DIC(0)="AEMQ" D ^DIC … … 29 29 Q 30 30 ; 31 XPAT(DFN,XPARMS,DIR,FN) 31 XPAT(DFN,XPARMS,DIR,FN) ; EXPORT ONE PATIENT TO A FILE 32 32 ; DIR IS THE DIRECTORY, DEFAULTS IF NULL TO ^TMP("C0CCCR","ODIR") 33 33 ; FN IS FILE NAME, DEFAULTS IF NULL … … 41 41 S OARY=$NA(^TMP("C0CCCR",$J,DFN,"CCR",1)) 42 42 S ONAM=UFN 43 I UFN="" S ONAM="PAT_"_DFN_"_CCR_V1_0_ 22.xml"43 I UFN="" S ONAM="PAT_"_DFN_"_CCR_V1_0_0.xml" 44 44 S ODIRGLB=$NA(^TMP("C0CCCR","ODIR")) 45 45 S ^TMP("C0CCCR","FNAME",DFN)=ONAM ; FILE NAME FOR BATCH USE … … 57 57 Q 58 58 ; 59 DCCR(DFN) 59 DCCR(DFN) ; DISPLAY A CCR THAT HAS JUST BEEN EXTRACTED 60 60 ; 61 61 N G1 … … 66 66 Q 67 67 ; 68 CCRRPC(CCRGRTN,DFN,CCRPARMS,CCRPART) 68 CCRRPC(CCRGRTN,DFN,CCRPARMS,CCRPART) ;RPC ENTRY POINT FOR CCR OUTPUT 69 69 ; CCRGRTN IS RETURN ARRAY PASSED BY NAME 70 70 ; DFN IS PATIENT IEN … … 131 131 Q 132 132 ; 133 INITSTPS(TAB) 133 INITSTPS(TAB) ; INITIALIZE CCR PROCESSING STEPS 134 134 ; TAB IS PASSED BY NAME 135 135 I DEBUG W "TAB= ",TAB,! … … 143 143 Q 144 144 ; 145 HDRMAP(CXML,DFN) 145 HDRMAP(CXML,DFN) ; MAP HEADER VARIABLES: FROM, TO ECT 146 146 N VMAP S VMAP=$NA(^TMP("C0CCCR",$J,DFN,"HEADER")) 147 147 ; K @VMAP … … 167 167 Q 168 168 ; 169 ACTLST(AXML,ACTRTN) 169 ACTLST(AXML,ACTRTN) ; RETURN THE ACTOR LIST FOR THE XML IN AXML 170 170 ; AXML AND ACTRTN ARE PASSED BY NAME 171 171 ; EACH ACTOR RECORD HAS 3 PARTS - IE IF OBJECTID=ACTORPATIENT_2 … … 192 192 Q 193 193 ; 194 TEST 194 TEST ; RUN ALL THE TEST CASES 195 195 D TESTALL^C0CUNIT("C0CCCR") 196 196 Q 197 197 ; 198 ZTEST(WHICH) 198 ZTEST(WHICH) ; RUN ONE SET OF TESTS 199 199 N ZTMP 200 200 D ZLOAD^C0CUNIT("ZTMP","C0CCCR") … … 202 202 Q 203 203 ; 204 TLIST 204 TLIST ; LIST THE TESTS 205 205 N ZTMP 206 206 D ZLOAD^C0CUNIT("ZTMP","C0CCCR") … … 238 238 ;;>>>D CCRRPC^C0CCCR(.C0C,"2","ALERTS","") 239 239 ;;>>?@C0C@(@C0C@(0))["</Alerts>" 240 240 -
ccr/trunk/p/C0CCCR0.m
r392 r508 1 C0CCCR0 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CCCR0 ; CCDCCR/GPL - CCR TEMPLATE AND ACCESS ROUTINES; 5/31/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 23 23 Q 24 24 ; 25 ZT(ZARY,BAT,LINE) 25 ZT(ZARY,BAT,LINE) ; private routine to add a line to the ZARY array 26 26 ; ZARY IS PASSED BY NAME 27 27 ; BAT is a string identifying the section … … 38 38 Q 39 39 ; 40 ZLOAD(ZARY,ROUTINE) 40 ZLOAD(ZARY,ROUTINE) ; load tests into ZARY which is passed by reference 41 41 ; ZARY IS PASSED BY NAME 42 42 ; ZARY = name of the root, closed array format (e.g., "^TMP($J)") … … 58 58 Q 59 59 ; 60 LOAD(ARY) 60 LOAD(ARY) ; LOAD A CCR TEMPLATE INTO ARY PASSED BY NAME 61 61 D ZLOAD(ARY,"C0CCCR0") 62 62 ; ZWR @ARY -
ccr/trunk/p/C0CDPT.m
r415 r508 1 C0CDPT 2 ;; 0.2;CCRCCD;;Jun 15, 2008;1 C0CDPT ;WV/CCRCCD/SMH - Routines to Extract Patient Data for CCDCCR; 6/15/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ; 4 4 ; Copyright 2008 WorldVistA. Licensed under the terms of the GNU … … 87 87 ; You can obtain field numbers using the data dictionary 88 88 ; 89 FAMILY(DFN) 90 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 91 D NAMECOMP^XLFNAME(.NAME) 92 Q NAME("FAMILY") 93 GIVEN(DFN) 94 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 95 D NAMECOMP^XLFNAME(.NAME) 96 Q NAME("GIVEN") 97 MIDDLE(DFN) 98 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 99 D NAMECOMP^XLFNAME(.NAME) 100 Q NAME("MIDDLE") 101 SUFFIX(DFN) 102 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 103 D NAMECOMP^XLFNAME(.NAME) 104 Q NAME("SUFFIX") 105 DISPNAME(DFN) 106 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 107 ; "G" is Given Name First; "MXc" is Mixed Case, With Suffx Preceded by Comma 108 Q $$NAMEFMT^XLFNAME(.NAME,"G","MXc") 109 DOB(DFN) 89 FAMILY(DFN) ; Family Name 90 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 91 D NAMECOMP^XLFNAME(.NAME) 92 Q NAME("FAMILY") 93 GIVEN(DFN) ; Given Name 94 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 95 D NAMECOMP^XLFNAME(.NAME) 96 Q NAME("GIVEN") 97 MIDDLE(DFN) ; Middle Name 98 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 99 D NAMECOMP^XLFNAME(.NAME) 100 Q NAME("MIDDLE") 101 SUFFIX(DFN) ; Suffi Name 102 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 103 D NAMECOMP^XLFNAME(.NAME) 104 Q NAME("SUFFIX") 105 DISPNAME(DFN) ; Display Name 106 N NAME S NAME=$$GET1^DIQ(2,DFN,.01) 107 ; "G" is Given Name First; "MXc" is Mixed Case, With Suffx Preceded by Comma 108 Q $$NAMEFMT^XLFNAME(.NAME,"G","MXc") 109 DOB(DFN) ; Date of Birth 110 110 N DOB S DOB=$$GET1^DIQ(2,DFN,.03,"I") 111 111 ; Date in FM Date Format. Convert to UTC/ISO 8601. 112 112 Q $$FMDTOUTC^C0CUTIL(DOB,"D") 113 GENDER(DFN) 113 GENDER(DFN) ; Gender/Sex 114 114 Q $$GET1^DIQ(2,DFN,.02) ; 115 SSN(DFN) 115 SSN(DFN) ; SSN 116 116 Q $$GET1^DIQ(2,DFN,.09) 117 ADDRTYPE(DFN) 117 ADDRTYPE(DFN) ; Address Type 118 118 ; Vista only stores a home address for the patient. 119 119 Q "Home" 120 ADDR1(DFN) 120 ADDR1(DFN) ; Get Home Address line 1 121 121 Q $$GET1^DIQ(2,DFN,.111) 122 ADDR2(DFN) 122 ADDR2(DFN) ; Get Home Address line 2 123 123 ; Vista has Lines 2,3; CCR has only line 1,2; so compromise 124 124 N ADDLN2,ADDLN3 … … 126 126 Q:ADDLN3="" ADDLN2 127 127 Q ADDLN2_", "_ADDLN3 128 CITY(DFN) 128 CITY(DFN) ; Get City for Home Address 129 129 Q $$GET1^DIQ(2,DFN,.114) 130 STATE(DFN) 130 STATE(DFN) ; Get State for Home Address 131 131 Q $$GET1^DIQ(2,DFN,.115) 132 ZIP(DFN) 132 ZIP(DFN) ; Get Zip code for Home Address 133 133 Q $$GET1^DIQ(2,DFN,.116) 134 COUNTY(DFN) 134 COUNTY(DFN) ; Get County for our Address 135 135 Q $$GET1^DIQ(2,DFN,.117) 136 COUNTRY(DFN) 136 COUNTRY(DFN) ; Get Country for our Address 137 137 ; Unfortunately, it's not stored anywhere in Vista, so the inevitable... 138 138 Q "USA" 139 RESTEL(DFN) 139 RESTEL(DFN) ; Residential Telephone 140 140 Q $$GET1^DIQ(2,DFN,.131) 141 WORKTEL(DFN) 141 WORKTEL(DFN) ; Work Telephone 142 142 Q $$GET1^DIQ(2,DFN,.132) 143 EMAIL(DFN) 143 EMAIL(DFN) ; Email Adddress 144 144 Q $$GET1^DIQ(2,DFN,.133) 145 CELLTEL(DFN) 145 CELLTEL(DFN) ; Cell Phone 146 146 Q $$GET1^DIQ(2,DFN,.134) 147 NOK1FAM(DFN) 148 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 149 D NAMECOMP^XLFNAME(.NAME) 150 Q NAME("FAMILY") 151 NOK1GIV(DFN) 152 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 153 D NAMECOMP^XLFNAME(.NAME) 154 Q NAME("GIVEN") 155 NOK1MID(DFN) 156 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 157 D NAMECOMP^XLFNAME(.NAME) 158 Q NAME("MIDDLE") 159 NOK1SUF(DFN) 160 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 161 D NAMECOMP^XLFNAME(.NAME) 162 Q NAME("SUFFIX") 163 NOK1DISP(DFN) 164 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 165 ; "G" is Given Name First; "MXc" is Mixed Case, With Suffx Preceded by Comma 166 Q $$NAMEFMT^XLFNAME(.NAME,"G","MXc") 167 NOK1REL(DFN) 147 NOK1FAM(DFN) ; Next of Kin 1 (NOK1) Family Name 148 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 149 D NAMECOMP^XLFNAME(.NAME) 150 Q NAME("FAMILY") 151 NOK1GIV(DFN) ; NOK1 Given Name 152 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 153 D NAMECOMP^XLFNAME(.NAME) 154 Q NAME("GIVEN") 155 NOK1MID(DFN) ; NOK1 Middle Name 156 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 157 D NAMECOMP^XLFNAME(.NAME) 158 Q NAME("MIDDLE") 159 NOK1SUF(DFN) ; NOK1 Suffi Name 160 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 161 D NAMECOMP^XLFNAME(.NAME) 162 Q NAME("SUFFIX") 163 NOK1DISP(DFN) ; NOK1 Display Name 164 N NAME S NAME=$$GET1^DIQ(2,DFN,.211) 165 ; "G" is Given Name First; "MXc" is Mixed Case, With Suffx Preceded by Comma 166 Q $$NAMEFMT^XLFNAME(.NAME,"G","MXc") 167 NOK1REL(DFN) ; NOK1 Relationship to the patient 168 168 Q $$GET1^DIQ(2,DFN,.212) 169 NOK1ADD1(DFN) 169 NOK1ADD1(DFN) ; NOK1 Address 1 170 170 Q $$GET1^DIQ(2,DFN,.213) 171 NOK1ADD2(DFN) 171 NOK1ADD2(DFN) ; NOK1 Address 2 172 172 N ADDLN2,ADDLN3 173 173 S ADDLN2=$$GET1^DIQ(2,DFN,.214),ADDLN3=$$GET1^DIQ(2,DFN,.215) 174 174 Q:ADDLN3="" ADDLN2 175 175 Q ADDLN2_", "_ADDLN3 176 NOK1CITY(DFN) 176 NOK1CITY(DFN) ; NOK1 City 177 177 Q $$GET1^DIQ(2,DFN,.216) 178 NOK1STAT(DFN) 178 NOK1STAT(DFN) ; NOK1 State 179 179 Q $$GET1^DIQ(2,DFN,.217) 180 NOK1ZIP(DFN) 180 NOK1ZIP(DFN) ; NOK1 Zip Code 181 181 Q $$GET1^DIQ(2,DFN,.218) 182 NOK1HTEL(DFN) 182 NOK1HTEL(DFN) ; NOK1 Home Telephone 183 183 Q $$GET1^DIQ(2,DFN,.219) 184 NOK1WTEL(DFN) 184 NOK1WTEL(DFN) ; NOK1 Work Telephone 185 185 Q $$GET1^DIQ(2,DFN,.21011) 186 NOK1SAME(DFN) 186 NOK1SAME(DFN) ; Is NOK1's Address the same the patient? 187 187 Q $$GET1^DIQ(2,DFN,.2125) 188 NOK2FAM(DFN) 189 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 190 D NAMECOMP^XLFNAME(.NAME) 191 Q NAME("FAMILY") 192 NOK2GIV(DFN) 193 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 194 D NAMECOMP^XLFNAME(.NAME) 195 Q NAME("GIVEN") 196 NOK2MID(DFN) 197 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 198 D NAMECOMP^XLFNAME(.NAME) 199 Q NAME("MIDDLE") 200 NOK2SUF(DFN) 201 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 202 D NAMECOMP^XLFNAME(.NAME) 203 Q NAME("SUFFIX") 204 NOK2DISP(DFN) 205 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 206 ; "G" is Given Name First; "MXc" is Mixed Case, With Suffx Preceded by Comma 207 Q $$NAMEFMT^XLFNAME(.NAME,"G","MXc") 208 NOK2REL(DFN) 188 NOK2FAM(DFN) ; NOK2 Family Name 189 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 190 D NAMECOMP^XLFNAME(.NAME) 191 Q NAME("FAMILY") 192 NOK2GIV(DFN) ; NOK2 Given Name 193 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 194 D NAMECOMP^XLFNAME(.NAME) 195 Q NAME("GIVEN") 196 NOK2MID(DFN) ; NOK2 Middle Name 197 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 198 D NAMECOMP^XLFNAME(.NAME) 199 Q NAME("MIDDLE") 200 NOK2SUF(DFN) ; NOK2 Suffi Name 201 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 202 D NAMECOMP^XLFNAME(.NAME) 203 Q NAME("SUFFIX") 204 NOK2DISP(DFN) ; NOK2 Display Name 205 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191) 206 ; "G" is Given Name First; "MXc" is Mixed Case, With Suffx Preceded by Comma 207 Q $$NAMEFMT^XLFNAME(.NAME,"G","MXc") 208 NOK2REL(DFN) ; NOK2 Relationship to the patient 209 209 Q $$GET1^DIQ(2,DFN,.2192) 210 NOK2ADD1(DFN) 210 NOK2ADD1(DFN) ; NOK2 Address 1 211 211 Q $$GET1^DIQ(2,DFN,.2193) 212 NOK2ADD2(DFN) 212 NOK2ADD2(DFN) ; NOK2 Address 2 213 213 N ADDLN2,ADDLN3 214 214 S ADDLN2=$$GET1^DIQ(2,DFN,.2194),ADDLN3=$$GET1^DIQ(2,DFN,.2195) 215 215 Q:ADDLN3="" ADDLN2 216 216 Q ADDLN2_", "_ADDLN3 217 NOK2CITY(DFN) 217 NOK2CITY(DFN) ; NOK2 City 218 218 Q $$GET1^DIQ(2,DFN,.2196) 219 NOK2STAT(DFN) 219 NOK2STAT(DFN) ; NOK2 State 220 220 Q $$GET1^DIQ(2,DFN,.2197) 221 NOK2ZIP(DFN) 221 NOK2ZIP(DFN) ; NOK2 Zip Code 222 222 Q $$GET1^DIQ(2,DFN,.2198) 223 NOK2HTEL(DFN) 223 NOK2HTEL(DFN) ; NOK2 Home Telephone 224 224 Q $$GET1^DIQ(2,DFN,.2199) 225 NOK2WTEL(DFN) 225 NOK2WTEL(DFN) ; NOK2 Work Telephone 226 226 Q $$GET1^DIQ(2,DFN,.211011) 227 NOK2SAME(DFN) 227 NOK2SAME(DFN) ; Is NOK2's Address the same the patient? 228 228 Q $$GET1^DIQ(2,DFN,.21925) 229 EMERFAM(DFN) 230 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 231 D NAMECOMP^XLFNAME(.NAME) 232 Q NAME("FAMILY") 233 EMERGIV(DFN) 234 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 235 D NAMECOMP^XLFNAME(.NAME) 236 Q NAME("GIVEN") 237 EMERMID(DFN) 238 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 239 D NAMECOMP^XLFNAME(.NAME) 240 Q NAME("MIDDLE") 241 EMERSUF(DFN) 242 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 243 D NAMECOMP^XLFNAME(.NAME) 244 Q NAME("SUFFIX") 245 EMERDISP(DFN) 246 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 247 ; "G" is Given Name First; "MXc" is Mixed Case, With Suffx Preceded by Comma 248 Q $$NAMEFMT^XLFNAME(.NAME,"G","MXc") 249 EMERREL(DFN) 229 EMERFAM(DFN) ; Emergency Contact (EMER) Family Name 230 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 231 D NAMECOMP^XLFNAME(.NAME) 232 Q NAME("FAMILY") 233 EMERGIV(DFN) ; EMER Given Name 234 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 235 D NAMECOMP^XLFNAME(.NAME) 236 Q NAME("GIVEN") 237 EMERMID(DFN) ; EMER Middle Name 238 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 239 D NAMECOMP^XLFNAME(.NAME) 240 Q NAME("MIDDLE") 241 EMERSUF(DFN) ; EMER Suffi Name 242 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 243 D NAMECOMP^XLFNAME(.NAME) 244 Q NAME("SUFFIX") 245 EMERDISP(DFN) ; EMER Display Name 246 N NAME S NAME=$$GET1^DIQ(2,DFN,.331) 247 ; "G" is Given Name First; "MXc" is Mixed Case, With Suffx Preceded by Comma 248 Q $$NAMEFMT^XLFNAME(.NAME,"G","MXc") 249 EMERREL(DFN) ; EMER Relationship to the patient 250 250 Q $$GET1^DIQ(2,DFN,.331) 251 EMERADD1(DFN) 251 EMERADD1(DFN) ; EMER Address 1 252 252 Q $$GET1^DIQ(2,DFN,.333) 253 EMERADD2(DFN) 253 EMERADD2(DFN) ; EMER Address 2 254 254 N ADDLN2,ADDLN3 255 255 S ADDLN2=$$GET1^DIQ(2,DFN,.334),ADDLN3=$$GET1^DIQ(2,DFN,.335) 256 256 Q:ADDLN3="" ADDLN2 257 257 Q ADDLN2_", "_ADDLN3 258 EMERCITY(DFN) 258 EMERCITY(DFN) ; EMER City 259 259 Q $$GET1^DIQ(2,DFN,.336) 260 EMERSTAT(DFN) 260 EMERSTAT(DFN) ; EMER State 261 261 Q $$GET1^DIQ(2,DFN,.337) 262 EMERZIP(DFN) 262 EMERZIP(DFN) ; EMER Zip Code 263 263 Q $$GET1^DIQ(2,DFN,.338) 264 EMERHTEL(DFN) 264 EMERHTEL(DFN) ; EMER Home Telephone 265 265 Q $$GET1^DIQ(2,DFN,.339) 266 EMERWTEL(DFN) 266 EMERWTEL(DFN) ; EMER Work Telephone 267 267 Q $$GET1^DIQ(2,DFN,.33011) 268 EMERSAME(DFN) 268 EMERSAME(DFN) ; Is EMER's Address the same the NOK? 269 269 Q $$GET1^DIQ(2,DFN,.3305) -
ccr/trunk/p/C0CFM1.m
r404 r508 1 C0CFM1 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CFM1 ; CCDCCR/GPL - CCR FILEMAN utilities; 12/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2009 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 22 22 Q 23 23 ; 24 PUTRIM(DFN,ZWHICH) 24 PUTRIM(DFN,ZWHICH) ;DFN IS PATIENT , WHICH IS ELEMENT TYPE 25 25 ; 26 26 S C0CGLB=$NA(^TMP("GPLRIM","VARS",DFN)) … … 37 37 Q 38 38 ; 39 PUTRIM1(DFN,ZZTYP,ZVARS) 39 PUTRIM1(DFN,ZZTYP,ZVARS) ; PUT ONE SECTION OF VARIABLES INTO CCR ELEMENTS 40 40 ; ZVARS IS PASSED BY NAME AN HAS THE FORM @ZVARS@(1,"VAR1")="VAL1" 41 41 S C0CX=0 … … 46 46 Q 47 47 ; 48 PUTELS(DFN,ZTYPE,ZOCC,ZVALS) 48 PUTELS(DFN,ZTYPE,ZOCC,ZVALS) ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE 49 49 ; ^C0C(171.201, DFN IS THE PATIENT IEN PASSED BY VALUE 50 50 ; ZTYPE IS THE NODE TYPE IE RESULTS,PROBLEMS PASSED BY VALUE … … 93 93 Q 94 94 ; 95 VARPTR(ZVAR,ZTYP) 95 VARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE 96 96 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO 97 97 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO … … 115 115 Q ZVARN 116 116 ; 117 BLDTYPS 117 BLDTYPS ; ROUTINE TO POPULATE THE CCR NODE TYPES FILE (^C0CDIC(170.101,) 118 118 ; THE CCR DICTIONARY (^C0CDIC(170, ) HAS MOST OF WHAT'S NEEDED 119 119 ; … … 123 123 Q 124 124 ; 125 FIXSEC 125 FIXSEC ;FIX THE SECTION FIELD OF THE CCR DICTIONARY.. IT HAS BEEN REDEFINED 126 126 ; AS A POINTER TO CCR NODE TYPE INSTEAD OF BEING A SET 127 127 ; THE SET VALUES ARE PRESERVED IN ^KBAI("SECTION") TO FACILITATE THIS … … 140 140 Q 141 141 ; 142 SETFDA(C0CSN,C0CSV) 142 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN 143 143 ; TO SET TO VALUE C0CSV. 144 144 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE … … 150 150 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV 151 151 Q 152 ZFILE(ZFN,ZTAB) 152 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED 153 153 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN) 154 154 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 158 158 E S ZR="" 159 159 Q ZR 160 ZFIELD(ZFN,ZTAB) 160 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED 161 161 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN) 162 162 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 167 167 Q ZR 168 168 ; 169 ZVALUE(ZFN,ZTAB) 169 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED 170 170 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN) 171 171 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA -
ccr/trunk/p/C0CFM2.m
r433 r508 1 C0CFM2 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CFM2 ; CCDCCR/GPL - CCR FILEMAN utilities; 12/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2009 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 28 28 Q 29 29 ; 30 RIMTBL(ZWHICH) 30 RIMTBL(ZWHICH) ; PUT ALL PATIENT IN RIMTBL ZWHICH INTO THE CCR ELEMENTS FILE 31 31 ; 32 32 I '$D(RIMBASE) D ASETUP^C0CRIMA ; FOR COMMAND LINE CALLS … … 39 39 Q 40 40 ; 41 PUTRIM(DFN,ZWHICH) 41 PUTRIM(DFN,ZWHICH) ;DFN IS PATIENT , WHICH IS ELEMENT TYPE 42 42 ; 43 43 S C0CGLB=$NA(^TMP("C0CRIM","VARS",DFN)) … … 54 54 Q 55 55 ; 56 PUTRIM1(DFN,ZZTYP,ZVARS) 56 PUTRIM1(DFN,ZZTYP,ZVARS) ; PUT ONE SECTION OF VARIABLES INTO CCR ELEMENTS 57 57 ; ZVARS IS PASSED BY NAME AN HAS THE FORM @ZVARS@(1,"VAR1")="VAL1" 58 58 S C0CX=0 … … 78 78 Q 79 79 ; 80 PUTELS(DFN,ZTYPE,ZOCC,ZVALS) 80 PUTELS(DFN,ZTYPE,ZOCC,ZVALS) ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE 81 81 ; 171.101, ^C0CE DFN IS THE PATIENT IEN PASSED BY VALUE 82 82 ; ZTYPE IS THE NODE TYPE IE RESULTS,PROBLEMS PASSED BY VALUE … … 145 145 Q 146 146 ; 147 UPDIE 147 UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS 148 148 K ZERR 149 149 D CLEAN^DILF … … 156 156 Q 157 157 ; 158 CHECK 158 CHECK ; CHECKSUM EXPERIMENTS 159 159 ; 160 160 ;B … … 165 165 Q 166 166 ; 167 CHKELS(DFN) 167 CHKELS(DFN) ; CHECKSUM ALL ELEMENTS FOR A PATIENT 168 168 ; 169 169 S ZGLB=$NA(^TMP("C0CCHK")) … … 186 186 Q 187 187 ; 188 DOIT(DFN) 188 DOIT(DFN) ; EXPERIMENT FOR TIMING CALLS USING mumps -dir DOIT^C0CFM2(DFN) 189 189 D SETXUP 190 190 D CHKELS(DFN) 191 191 Q 192 192 ; 193 SETXUP 193 SETXUP ; SET UP ENVIRONMENT 194 194 S DISYS=19 195 195 S DT=3090325 … … 224 224 Q 225 225 ; 226 PUTELSOLD(DFN,ZTYPE,ZOCC,ZVALS) 226 PUTELSOLD(DFN,ZTYPE,ZOCC,ZVALS) ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE 227 227 ; 171.101, ^C0CE DFN IS THE PATIENT IEN PASSED BY VALUE 228 228 ; ZTYPE IS THE NODE TYPE IE RESULTS,PROBLEMS PASSED BY VALUE … … 278 278 Q 279 279 ; 280 VARPTR(ZVAR,ZTYP) 280 VARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE 281 281 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO 282 282 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO … … 300 300 Q ZVARN 301 301 ; 302 BLDTYPS 302 BLDTYPS ; ROUTINE TO POPULATE THE CCR NODE TYPES FILE (^C0CDIC(170.101,) 303 303 ; THE CCR DICTIONARY (^C0CDIC(170, ) HAS MOST OF WHAT'S NEEDED 304 304 ; … … 308 308 Q 309 309 ; 310 FIXSEC 310 FIXSEC ;FIX THE SECTION FIELD OF THE CCR DICTIONARY.. IT HAS BEEN REDEFINED 311 311 ; AS A POINTER TO CCR NODE TYPE INSTEAD OF BEING A SET 312 312 ; THE SET VALUES ARE PRESERVED IN ^KBAI("SECTION") TO FACILITATE THIS … … 325 325 Q 326 326 ; 327 SETFDA(C0CSN,C0CSV) 327 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN 328 328 ; TO SET TO VALUE C0CSV. 329 329 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE … … 335 335 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV 336 336 Q 337 ZFILE(ZFN,ZTAB) 337 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED 338 338 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN) 339 339 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 343 343 E S ZR="" 344 344 Q ZR 345 ZFIELD(ZFN,ZTAB) 345 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED 346 346 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN) 347 347 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 352 352 Q ZR 353 353 ; 354 ZVALUE(ZFN,ZTAB) 354 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED 355 355 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN) 356 356 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA -
ccr/trunk/p/C0CIMMU.m
r396 r508 1 C0CIMMU 2 ;; 0.1;CCDCCR;nopatch;noreleasedate;Build 71 C0CIMMU ; CCDCCR/GPL - CCR/CCD PROCESSING FOR IMMUNIZATIONS ; 2/2/09 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 22 22 ; PROCESS THE IMMUNIZATIONS SECTION OF THE CCR 23 23 ; 24 MAP(IPXML,DFN,OUTXML) 24 MAP(IPXML,DFN,OUTXML) ; MAP IMMUNIZATIONS 25 25 ; 26 26 N C0CZV,C0CZVI ; TO STORE MAPPED VARIABLES … … 47 47 Q 48 48 ; 49 EXTRACT(IPXML,DFN,OUTXML) 49 EXTRACT(IPXML,DFN,OUTXML) ; EXTRACT IMMUNIZATIONS INTO VARIABLES 50 50 ; 51 51 ; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED -
ccr/trunk/p/C0CLA7Q.m
r505 r508 1 1 C0CLA7Q ;WV/JMC - CCD/CCR Lab HL7 Query Utility ;May 4, 2009 2 ;;n.n;;****; 3 ; 4 ; 5 Q 6 ; 7 ; 2 ;;1.0;C0C;;May 19, 2009; 3 ;;n.n;;****; 4 ; 5 ; 6 Q 7 ; 8 ; 8 9 LAB(C0CPTID,C0CSDT,C0CEDT,C0CSC,C0CSPEC,C0CERR,C0CDEST,C0CHL7) ; Entry point for Lab Result Query 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 10 ; 11 ; 12 K ^TMP("C0C-VLAB",$J) 13 ; 14 ; Check and retrieve lab results from LAB DATA file (#63) 15 S C0CDEST=$$GCPR^LA7QRY($G(C0CPTID),$G(C0CSDT),$G(C0CEDT),.C0CSC,.C0CSPEC,.C0CERR,$G(C0CDEST),$G(C0CHL7)) 16 ; 17 ; If V LAB file present then check for lab results that are only in this file 18 ; If results found in V Lab file then build results and add to above results. 19 I $D(^AUPNVLAB) D 20 . D VCHECK 21 . I $D(^TMP("C0C-VLAB",$J,3)) D VBUILD 22 ; 23 ;K ^TMP("C0C-VLAB",$J) 24 ; 25 Q C0CDEST 26 ; 27 ; 27 28 VCHECK ; If V LAB file present then check for lab results that are only in this file. 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 29 ; 30 N C0CDA,C0CEND,C0CROOT,C0CVLAB,LA7PTID,LA7SC,LA7SCRC,LA7SPEC 31 ; 32 S LA7PTID=C0CPTID 33 D PATID^LA7QRY2 34 I $D(LA7ERR) Q 35 ; 36 ; Resolve search codes to lab datanames 37 S LA7SC=$G(C0CSC) 38 I $T(SCLIST^LA7QRY2)'="" D 39 . N TMP 40 . S LA7SCSRC=$G(C0CSC) 41 . S TMP=$$SCLIST^LA7QRY2(LA7SCSRC) 42 . S LA7SC=TMP 43 ; 44 I LA7SC'="*" D CHKSC^LA7QRY1 45 ; 46 ; Convert specimen codes to file #61 Topography entries 47 S LA7SPEC=$G(C0CSPEC) 48 I LA7SPEC'="*" D SPEC^LA7QRY1 49 ; 50 S C0CROOT="^AUPNVLAB(""ALR4"",DFN,C0CSDT)",C0CEND=0 51 ; 52 F S C0CROOT=$Q(@C0CROOT) Q:C0CROOT="" D Q:C0CEND 53 . I $QS(C0CROOT,1)'="ALR4"!($QS(C0CROOT,2)'=DFN) S C0CEND=1 Q ; Left x-ref or patient 54 . I $QS(C0CROOT,3)>C0CEDT S C0CEND=1 Q ; Exceeded end date/time 55 . S C0CDA=$QS(C0CROOT,4) 56 . I $D(^TMP("C0C-VLAB",$J,1,C0CDA)) Q ; Already checked during scan of file #63 57 . I $P($G(^AUPNVLAB(C0CDA,11)),"^",8)=1 Q ; Source is LAB DATA file - skip 58 . D VCHK1 59 ; 60 ; 61 Q 62 ; 63 ; 63 64 VBUILD ; Build results found only in V LAB file into HL7 structure. 64 65 66 67 68 65 ; 66 ; 67 Q 68 ; 69 ; 69 70 LNCHK ; Check for corresponding entry in V LAB file and related LOINC code for a result in file #63. 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 71 ; Call from LA7QRY2 72 ; 73 N DFN,C0C60,C0C63,C0CACC,C0CDA,C0CDT,C0CLN,C0CPDA,C0CPTEST,C0CSPEC,C0CTEST,X 74 ; 75 S DFN=$P(^LR(LRDFN,0),"^",3) 76 S C0C63(0)=^LR(LRDFN,LRSS,LRIDT,0) 77 S C0CDT=$P(C0C63(0),"^"),C0CACC=$P(C0C63(0),"^",6),C0CSPEC=$P(C0C63(0),"^",5) 78 S (C0CTEST,C0CTEST(64),C0CPTEST,C0CPTEST(64),C0CLN)="" 79 ; 80 ; ^AUPNVLAB("ALR1",5380,"EKT 0307 48",173,3080307.211055,5427197)="" 81 ; 82 S C0C60="" 83 F S C0C60=$O(^LAB(60,"C",LRSS_";"_LRSB_";1",C0C60)) Q:'C0C60 D Q:C0CLN'="" 84 . D FINDDT 85 . I C0CDA<1 Q 86 . I $P($G(^AUPNVLAB(C0CDA,11)),"^",8)'=1 Q ; Source is not LAB DATA file - skip 87 . S C0CLN=$P($G(^AUPNVLAB(C0CDA,11)),"^",13) 88 . S C0CPDA=$P($G(^AUPNVLAB(C0CDA,12)),"^",8) 89 . I C0CPDA="" S C0CPDA=C0CDA 90 . S C0CTEST=$P($G(^AUPNVLAB(C0CDA,0)),"^"),X=$P($G(^LAB(60,C0CTEST,64)),"^",2) 91 . I X S C0CTEST(64)=$P($G(^LAM(X,0)),"^",2) 92 . S C0CPTEST=$P($G(^AUPNVLAB(C0CPDA,0)),"^"),X=$P($G(^LAB(60,C0CPTEST,64)),"^") 93 . I X S C0CPTEST(64)=$P($G(^LAM(X,0)),"^",2) 94 . S ^TMP("C0C-VLAB",$J,1,C0CDA)="" 95 . I C0CDA'=C0CPDA S ^TMP("C0C-VLAB",$J,1,C0CPDA)="" 96 . S ^TMP("C0C-VLAB",$J,2,LRDFN,LRSS,LRIDT,LRSB)=C0CPTEST(64)_"^"_C0CTEST(64)_"^"_C0CLN_"^"_C0CDA_"^"_C0CTEST_"^"_C0CPDA_"^"_C0CPTEST 97 ; 98 S X=$P(LA7X,"^",3) 99 ; If order NLT then update if no order NLT 100 I C0CPTEST(64),$P(X,"!")="" S $P(X,"!")=C0CPTEST(64) 101 ; 102 ; If result NLT then update if no result NLT 103 I C0CTEST(64),$P(X,"!",2)="" S $P(X,"!",2)=C0CTEST(64) 104 ; 105 ; If LOINC found then update variable with LN code 106 I C0CLN'="",$P(X,"!",3)="" S $P(X,"!",3)=C0CLN 107 ; 108 S $P(LA7X,"^",3)=X 109 ; 110 Q 111 ; 112 ; 112 113 TMPCHK ; Check if LN/NLT codes saved from V LAB file above and use when building OBR/OBX segments 113 114 115 116 117 118 119 120 121 122 123 124 114 ; Called from LA7VOBX1 115 ; 116 N I,X 117 ; 118 S X=$G(^TMP("C0C-VLAB",$J,2,LRDFN,LRSS,LRIDT,LRSB)) 119 I X="" Q 120 F I=1:1:3 I $P(LA7X,"!",I)="",$P(X,"^",I)'="" S $P(LA7X,"!",I)=$P(X,"^",I) 121 S $P(LA7VAL,"^",3)=LA7X 122 ; 123 Q 124 ; 125 ; 125 126 VCHK1 ; Check the entry in V Lab to determine if it meets criteria 126 127 128 129 130 131 132 133 134 135 136 127 ; 128 N C0CVLAB,I 129 ; 130 F I=0,12 S C0CVLAB(I)=$G(^AUPNVLAB(C0CDA,I)) 131 ; 132 ; JMC 04/13/09 - Store anything for now that meets date criteria. 133 D VSTORE 134 ; 135 Q 136 ; 137 ; 137 138 VSTORE ; Store entry for building in HL7 message when parent is from V LAB file. 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 139 ; 140 N C0CPDA,C0CPTEST 141 ; 142 ; Determine parent test to use for OBR segment 143 S C0CPDA=$P(C0CVLAB(12),"^",8) 144 I C0CPDA="" S C0CPDA=C0CDA 145 ; 146 ; Determine parent test 147 S C0CPTEST=$P($G(^AUPNVLAB(C0CPDA,0)),"^") 148 ; 149 S ^TMP("C0C-VLAB",$J,3,$P(C0CVLAB(0),"^",2),$P(C0CVLAB(12),"^"),C0CPTEST,C0CDA)=C0CPDA 150 ; 151 Q 152 ; 153 ; 153 154 FINDDT ; Find entry in V LAB for the date/time or one close to it. 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 155 ; RPMS stores related specimen entries under the same date/time. 156 ; Lab file #63 creates unique entries with slightly different times. 157 ; 158 S C0CDA=$O(^AUPNVLAB("ALR1",DFN,C0CACC,C0C60,C0CDT,0)) 159 I C0CDA>0 Q 160 ; 161 ; If entry found then confirm that specimen type matches. 162 N C0CDTY 163 S C0CDTY=$O(^AUPNVLAB("ALR1",DFN,C0CACC,C0C60,0)) 164 I C0CDTY D 165 . I $P(C0CDT,".")'=$P(C0CDTY,".") Q 166 . S C0CDA=$O(^AUPNVLAB("ALR1",DFN,C0CACC,C0C60,C0CDTY,0)) 167 . I C0CSPEC'=$P($G(^AUPNVLAB(C0CDA,11)),"^",3) S C0CDA="" 168 ; 169 Q -
ccr/trunk/p/C0CLABS.m
r435 r508 1 C0CALABS 2 ;; 0.3;CCDCCR;nopatch;noreleasedate1 C0CALABS ; CCDCCR/GPL - CCR/CCD PROCESSING FOR LAB RESULTS ; 10/01/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 19 19 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 20 ; 21 ;MAP(DFN,MOXML,MIVAR,MIXML) ; MAP RESULTS VARIABLES TO XML - GPL -TBD 22 MAP(MIXML,DFN,MOXML) ;TO MAKE THIS COMPATIBLE WITH OLD CALLING FOR EXTRACT 21 MAP(MIXML,DFN,MOXML) ;TO MAKE THIS COMPATIBLE WITH OLD CALLING FOR EXTRACT 23 22 ; ASSUMES THAT EXTRACT HAS BEEN RUN AND THE VARIABLES STORED IN MIVAR 24 23 ; MIXML,MIVAR, AND MOXML ARE PASSED BY NAME … … 38 37 Q 39 38 ; 40 RPCMAP(RTN,DFN,RMIVAR,RMIXML) 39 RPCMAP(RTN,DFN,RMIVAR,RMIXML) ; RPC ENTRY POINT FOR MAPPING RESULTS 41 40 ; RTN IS PASSED BY REFERENCE 42 41 ;N C0CT0,C0CT,C0CV ; CCR TEMPLATE, RESULTS SUBTEMPLATE, VARIABLES … … 115 114 Q 116 115 ; 117 EXTRACT(ILXML,DFN,OLXML) 116 EXTRACT(ILXML,DFN,OLXML) ; EXTRACT LABS INTO THE C0CLVAR GLOBAL 118 117 ; 119 118 ; LABXML AND LABOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED … … 136 135 Q 137 136 ; 138 GHL7 137 GHL7 ; GET HL7 MESSAGE FOR LABS FOR THIS PATIENT 139 138 ; N C0CPTID,C0CSPC,C0CSDT,C0CEDT,C0CR 140 139 ; SET UP FOR LAB API CALL … … 156 155 Q 157 156 ; 158 LIST 157 LIST ; LIST THE HL7 MESSAGE; ALSO, EXTRACT THE RESULT VARIABLES TO C0CLB 159 158 ; 160 159 ; N C0CI,C0CJ,C0COBT,C0CHB,C0CVAR … … 230 229 ;M ^TMP("C0CRIM","VARS",DFN,"RESULTS")=@C0CLB 231 230 Q 232 LTYP(OSEG,OTYP,OVARA,OC0CQT) 231 LTYP(OSEG,OTYP,OVARA,OC0CQT) ; 233 232 S OTAB=$NA(@C0CTAB@(OTYP)) ; TABLE FOR SEGMENT TYPE 234 233 I '$D(OC0CQT) S C0CQT=0 ; NOT C0CQT IS DEFAULT … … 247 246 . . . I OV'="" W OI_": "_$P(@OTAB@(OI),"^",3),": ",OVAR,": ",OV,! 248 247 Q 249 LOBX 250 Q 251 ; 252 OUT(DFN) 248 LOBX ; 249 Q 250 ; 251 OUT(DFN) ; WRITE OUT A CCR THAT HAS JUST BEEN PROCESSED (FOR TESTING) 253 252 N GA,GF,GD 254 253 S GA=$NA(^TMP("C0CCCR",$J,DFN,"CCR",1)) … … 258 257 Q 259 258 ; 260 SETTBL 259 SETTBL ; 261 260 K X ; CLEAR X 262 261 S X("PID","PID1")="1^00104^Set ID - Patient ID" -
ccr/trunk/p/C0CMED.m
r426 r508 1 1 C0CMED ; WV/CCDCCR/GPL/SMH - CCR/CCD Medications Driver; Mar 23 2009 2 ;;0.6;CCDCCR;;JUL 16,2008;3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 ;;1.0;C0C;;May 19, 2009; 3 ; Copyright 2008,2009 George Lilly, University of Minnesota and Sam Habiel. 4 ; Licensed under the terms of the GNU General Public License. 5 ; See attached copy of the License. 6 ; 7 ; This program is free software; you can redistribute it and/or modify 8 ; it under the terms of the GNU General Public License as published by 9 ; the Free Software Foundation; either version 2 of the License, or 10 ; (at your option) any later version. 11 ; 12 ; This program is distributed in the hope that it will be useful, 13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ; GNU General Public License for more details. 16 ; 17 ; You should have received a copy of the GNU General Public License along 18 ; with this program; if not, write to the Free Software Foundation, Inc., 19 ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 ; 21 ; --Revision History 22 ; July 2008 - Initial Version/GPL 23 ; July 2008 - March 2009 various revisions 24 ; March 2009 - Reconstruction of routine as driver for other med routines/SMH 25 ; 26 Q 27 27 EXTRACT(MEDXML,DFN,MEDOUTXML) ; Private; Extract medications into provided XML template 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 28 ; DFN passed by reference 29 ; MEDXML and MEDOUTXML are passed by Name 30 ; MEDXML is the input template 31 ; MEDOUTXML is the output template 32 ; Both of them refer to ^TMP globals where the XML documents are stored 33 ; 34 ; -- This ep is the driver for extracting medications into the provided XML template 35 ; 1. VA Outpatient Meds are in C0CMED1 36 ; 2. VA Pending Meds are in C0CMED2 37 ; 3. VA non-VA Meds are in C0CMED3 38 ; 4. VA Inpatient IV Meds are in C0CMED4 (not functional) 39 ; 5. VA Inpatient UD Meds are in C0CMED5 (doesn't exist yet)--March 2009 40 ; 6. RPMS Meds are in C0CMED6. Need to create other routines for subdivisions of RPMS Meds is not known at this time. 41 ; 42 ; --Get parameters for meds 43 S @MEDOUTXML@(0)=0 ; By default, empty. 44 N C0CMFLAG 45 S C0CMFLAG=$$GET^C0CPARMS("MEDALL")_"^"_$$GET^C0CPARMS("MEDLIMIT")_"^"_$$GET^C0CPARMS("MEDACTIVE")_"^"_$$GET^C0CPARMS("MEDPENDING") 46 W:$G(DEBUG) "Med Parameters: ",! 47 W:$G(DEBUG) "ALL: ",+C0CMFLAG,! 48 W:$G(DEBUG) "LIMIT: ",$P(C0CMFLAG,U,2),! 49 W:$G(DEBUG) "ACTIVE: ",$P(C0CMFLAG,U,3),! 50 W:$G(DEBUG) "PEND: ",$P(C0CMFLAG,U,4),! 51 ; --Find out what system we are on and branch out... 52 W:$G(DEBUG) "Agenecy: ",$G(DUZ("AG")) 53 I $$RPMS^C0CUTIL() D RPMS QUIT 54 I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VISTA QUIT 55 55 RPMS 56 56 D EXTRACT^C0CMED6(MEDXML,DFN,MEDOUTXML,C0CMFLAG) QUIT 57 57 VISTA 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 58 N MEDCOUNT S MEDCOUNT=0 59 K ^TMP($J,"MED") 60 N HIST S HIST=$NA(^TMP($J,"MED","HIST")) ; Meds already dispensed 61 N PEND S PEND=$NA(^TMP($J,"MED","PEND")) ; Pending Meds 62 N NVA S NVA=$NA(^TMP($J,"MED","NVA")) ; non-VA Meds 63 S @HIST@(0)=0,@PEND@(0)=0,@NVA@(0)=0 ; At first, they are all empty... (prevent undefined errors) 64 ; N IPIV ; Inpatient IV Meds 65 ; N IPUD ; Inpatient UD Meds 66 D EXTRACT^C0CMED1(MEDXML,DFN,HIST,.MEDCOUNT,C0CMFLAG) ; Historical OP Meds 67 D:$P(C0CMFLAG,U,4) EXTRACT^C0CMED2(MEDXML,DFN,PEND,.MEDCOUNT) ; Pending Meds 68 D:+C0CMFLAG EXTRACT^C0CMED3(MEDXML,DFN,NVA,.MEDCOUNT) ; non-VA Meds 69 I @HIST@(0)>0 D 70 . D CP^C0CXPATH(HIST,MEDOUTXML) 71 . W:$G(DEBUG) "HAS ACTIVE OP MEDS",! 72 I @PEND@(0)>0 D 73 . I @HIST@(0)>0 D INSINNER^C0CXPATH(MEDOUTXML,PEND) ;Add Pending to Historical 74 . E D CP^C0CXPATH(PEND,MEDOUTXML) ; No historical, just copy 75 . W:$G(DEBUG) "HAS OP PENDING MEDS",! 76 I @NVA@(0)>0 D 77 . I @HIST@(0)>0!(@PEND@(0)>0) D INSINNER^C0CXPATH(MEDOUTXML,NVA) 78 . E D CP^C0CXPATH(NVA,MEDOUTXML) 79 . W:$G(DEBUG) "HAS NON-VA MEDS",! 80 Q 81 -
ccr/trunk/p/C0CMED1.m
r426 r508 1 1 C0CMED1 ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS ;01/10/09 2 ;;0.1;CCDCCR;;JUL 16,2008;3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2 ;;1.0;C0C;;May 19, 2009; 3 ;;Last modified Sat Jan 10 21:42:27 PST 2009 4 ; Copyright 2009 WorldVistA. Licensed under the terms of the GNU 5 ; General Public License See attached copy of the License. 6 ; 7 ; This program is free software; you can redistribute it and/or modify 8 ; it under the terms of the GNU General Public License as published by 9 ; the Free Software Foundation; either version 2 of the License, or 10 ; (at your option) any later version. 11 ; 12 ; This program is distributed in the hope that it will be useful, 13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ; GNU General Public License for more details. 16 ; 17 ; You should have received a copy of the GNU General Public License along 18 ; with this program; if not, write to the Free Software Foundation, Inc., 19 ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 ; 21 W "NO ENTRY FROM TOP",! 22 Q 23 ; 24 24 EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT,FLAGS) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 25 ; 26 ; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED 27 ; INXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE 28 ; 29 ; MEDS is return array from RPC. 30 ; MAP is a mapping variable map (store result) for each med 31 ; MED is holds each array element from MEDS(J), one medicine 32 ; MEDCOUNT is a counter passed by Reference. 33 ; FLAGS are: MEDALL(bool)^MEDLIMIT(int)^MEDACTIVE(bool)^MEDPENDING(bool) 34 ; FLAGS are set-up in C0CMED. 35 ; 36 ; RX^PSO52API is a Pharmacy Re-Enginnering (PRE) API to get all 37 ; med data available. 38 ; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf 39 ; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS). 40 ; D PARY^C0CXPATH(MINXML) 41 N MEDS,MAP 42 K ^TMP($J,"CCDCCR") ; PLEASE DON'T KILL ALL OF ^TMP($J) HERE!!!! 43 N ALL S ALL=+FLAGS 44 N ACTIVE S ACTIVE=$P(FLAGS,U,3) 45 ; Below, X1 is today; X2 is the number of days we want to go back 46 ; X is the result of this calculation using C^%DTC. 47 N X,X1,X2 48 S X1=DT 49 S X2=-$P($P(FLAGS,U,2),"-",2) 50 D C^%DTC 51 ; I discovered that I shouldn't put an ending date (last parameter) 52 ; because it seems that it will get meds whose beginning is after X but 53 ; whose exipriation is before the ending date. 54 D RX^PSO52API(DFN,"CCDCCR","","","",X,"") 55 M MEDS=^TMP($J,"CCDCCR",DFN) 56 ; @(0) contains the number of meds or -1^NO DATA FOUND 57 ; If it is -1, we quit. 58 I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT 59 ZWRITE:$G(DEBUG) MEDS 60 N RXIEN S RXIEN=0 61 F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="" D ; FOR EACH MEDICATION IN THE LIST 62 . N MED M MED=MEDS(RXIEN) 63 . I 'ALL,ACTIVE,$P(MED(100),U,2)'="ACTIVE" QUIT 64 . S MEDCOUNT=MEDCOUNT+1 65 . W:$G(DEBUG) "RXIEN IS ",RXIEN,! 66 . S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCOUNT)) 67 . ; K @MAP DO NOT KILL HERE, WAS CLEARED IN C0CMED 68 . W:$G(DEBUG) "MAP= ",MAP,! 69 . S @MAP@("MEDOBJECTID")="MED"_MEDCOUNT ; MEDCOUNT FOR ID 70 . ; S @MAP@("MEDOBJECTID")="MED"_MED(.01) ;Rx Number 71 . S @MAP@("MEDISSUEDATETXT")="Issue Date" 72 . S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($P(MED(1),U)) 73 . S @MAP@("MEDLASTFILLDATETXT")="Last Fill Date" 74 . S @MAP@("MEDLASTFILLDATE")=$$FMDTOUTC^C0CUTIL($P(MED(101),U)) 75 . S @MAP@("MEDRXNOTXT")="Prescription Number" 76 . S @MAP@("MEDRXNO")=MED(.01) 77 . S @MAP@("MEDTYPETEXT")="Medication" 78 . S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses 79 . S @MAP@("MEDSTATUSTEXT")=$P(MED(100),U,2) 80 . S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$P(MED(4),U) 81 . S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(6),U,2) 82 . ; 12/30/08: I will be using RxNorm for coding... 83 . ; 176.001 is the file for Concepts; 176.003 is the file for 84 . ; sources (i.e. for RxNorm Version) 85 . ; 86 . ; We need the VUID first for the National Drug File entry first 87 . ; We get the VUID of the drug, by looking up the VA Product entry 88 . ; (file 50.68) using the call NDF^PSS50, returned in node 22. 89 . ; Field 99.99 is the VUID. 90 . ; 91 . ; We use the VUID to look up the RxNorm in file 176.001; same idea. 92 . ; Get IEN first using $$FIND1^DIC, then get the RxNorm number by 93 . ; $$GET1^DIQ. 94 . ; 95 . ; I get the RxNorm name and version from the RxNorm Sources (file 96 . ; 176.003), by searching for "RXNORM", then get the data. 97 . N MEDIEN S MEDIEN=$P(MED(6),U) 98 . D NDF^PSS50(MEDIEN,,,,,"NDF") 99 . N NDFDATA M NDFDATA=^TMP($J,"NDF",MEDIEN) 100 . N NDFIEN S NDFIEN=$P(NDFDATA(20),U) 101 . N VAPROD S VAPROD=$P(NDFDATA(22),U) 102 . ; 103 . ; NDFIEN is not necessarily defined; it won't be if the drug 104 . ; is not matched to the national drug file (e.g. if the drug is 105 . ; new on the market, compounded, or is a fake drug [blue pill]. 106 . ; To protect against failure, I will put an if/else block 107 . ; 108 . N VUID,RXNIEN,RXNORM,SRCIEN,RXNNAME,RXNVER 109 . I NDFIEN,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet. 110 . . S VUID=$$GET1^DIQ(50.68,VAPROD,99.99) 111 . . S RXNIEN=$$FIND1^DIC(176.001,,,VUID,"VUID") 112 . . S RXNORM=$$GET1^DIQ(176.001,RXNIEN,.01) 113 . . S SRCIEN=$$FIND1^DIC(176.003,,"B","RXNORM") 114 . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6) 115 . . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7) 116 . ; 117 . E S (RXNORM,RXNNAME,RXNVER)="" 118 . ; End if/else block 119 . S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM 120 . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME 121 . S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER 122 . ; 123 . S @MAP@("MEDBRANDNAMETEXT")=MED(6.5) 124 . D DOSE^PSS50(MEDIEN,,,,,"DOSE") 125 . N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN) 126 . S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901) 127 . S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2) 128 . ; Units, concentration, etc, come from another call 129 . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit 130 . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters 131 . ; NDF Entry IEN, and VA Product IEN 132 . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT") 133 . ; These have been collected above. 134 . N CONCDATA 135 . ; If a drug was not matched to NDF, then the NDFIEN is gonna be "" 136 . ; and this will crash the call. So... 137 . I NDFIEN="" S CONCDATA="" 138 . E S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD) 139 . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1) 140 . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3) 141 . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4) 142 . S @MAP@("MEDQUANTITYVALUE")=MED(7) 143 . ; Oddly, there is no easy place to find the dispense unit. 144 . ; It's not included in the original call, so we have to go to the drug file. 145 . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT") 146 . ; Node 14.5 is the Dispense Unit 147 . D DATA^PSS50(MEDIEN,,,,,"QTY") 148 . N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN) 149 . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5) 150 . ; 151 . ; --- START OF DIRECTIONS --- 152 . ; Sig data not in any API :-( Oh yes, you can get the whole thing, but... 153 . ; we want the compoenents. 154 . ; It's in node 6 of ^PSRX(IEN) 155 . ; So, here we go again 156 . ; ^PSRX(D0,6,D1,0)= (#.01) DOSAGE ORDERED [1F] ^ (#1) DISPENSE UNITS PER DOSE 157 . ; ==>[2N] ^ (#2) UNITS [3P:50.607] ^ (#3) NOUN [4F] ^ (#4) 158 . ; ==>DURATION [5F] ^ (#5) CONJUNCTION [6S] ^ (#6) ROUTE 159 . ; ==>[7P:51.2] ^ (#7) SCHEDULE [8F] ^ (#8) VERB [9F] ^ 160 . ; 161 . N DIRNUM S DIRNUM=0 ; Sigline number 162 . S DIRCNT=0 ; COUNT OF MULTIPLE DIRECTIONS 163 . F S DIRNUM=$O(^PSRX(RXIEN,6,DIRNUM)) Q:DIRNUM="" D 164 . . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT 165 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components. 166 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05. 167 . . N SIGDATA S SIGDATA=^PSRX(RXIEN,6,DIRNUM,0) 168 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$P(SIGDATA,U,9) 169 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$P(SIGDATA,U,1) 170 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT") 171 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient 172 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient 173 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient 174 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$$GET1^DIQ(51.2,$P(SIGDATA,U,7),.01) 175 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$P(SIGDATA,U,8) 176 . . ; Invervals... again another call. 177 . . ; In the wisdom of the original programmers, the schedule is a free text field 178 . . ; However, it gets translated by a call to the administration schedule file 179 . . ; to see if that schedule exists. 180 . . ; That's the same thing I am going to do. 181 . . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ). 182 . . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO-- 183 . . ; I looked), PSSFT is the name, and list is the ^TMP name to store the data in. 184 . . ; So... 185 . . D AP^PSS51P1("PSJ",$P(SIGDATA,U,8),,,"SCHEDULE") 186 . . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE") 187 . . N INTERVAL 188 . . I $P(SCHEDATA(0),U)=-1 S INTERVAL="" 189 . . E D 190 . . . N SUB S SUB=$O(SCHEDATA(0)) 191 . . . S INTERVAL=SCHEDATA(SUB,2) 192 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL 193 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute" 194 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$P(SIGDATA,U,5) 195 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")="" 196 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$P(SIGDATA,U,8)["PRN" 197 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")="" 198 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")="" 199 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")="" 200 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")="" 201 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")="" 202 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")="" 203 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")="" 204 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" 205 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM 206 . . N DIRMOD S DIRMOD=$P(SIGDATA,U,6) 207 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$S(DIRMOD="T":"THEN",DIRMOD="A":"AND",DIRMOD="X":"EXCEPT",1:"") 208 . ; 209 . ; --- END OF DIRECTIONS --- 210 . ; 211 . ; ^PSRX(22,"INS1",1,0)="FOR BLOOD PRESSURE" 212 . S @MAP@("MEDPTINSTRUCTIONS")=$G(^PSRX(RXIEN,"INS1",1,0)) 213 . ; ^PSRX(22,"PRC",1,0)="Pharmacist: you must obey my command" 214 . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=$G(^PSRX(RXIEN,"PRC",1,0)) 215 . S @MAP@("MEDRFNO")=MED(9) 216 . N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED")) 217 . K @RESULT 218 . D MAP^C0CXPATH(MINXML,MAP,RESULT) 219 . ; MAPPING DIRECTIONS 220 . N DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE 221 . N DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT 222 . D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1) 223 . D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions") 224 . ; N MDZ1,MDZNA 225 . I DIRCNT>0 D ; IF THERE ARE DIRCTIONS 226 . . F MDZ1=1:1:DIRCNT D ; FOR EACH DIRECTION 227 . . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",MDZ1)) 228 . . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2) 229 . . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication") 230 . I MEDCOUNT=1 D CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy 231 . E D INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER FIRST, INSERT INNER XML 232 N MEDTMP,MEDI 233 D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS 234 I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ 235 . W "MEDICATION MISSING ",! 236 . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),! 237 Q 238 ; -
ccr/trunk/p/C0CMED2.m
r421 r508 1 1 C0CMED2 ; WV/CCDCCR/SMH - CCR/CCD Meds - Pending for Vista 2 ;;0.1;CCDCCR;;JUL 16,2008;3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2 ;;1.0;C0C;;May 19, 2009; 3 ;;Last Modified Sat Jan 10 21:41:14 PST 2009 4 ; Copyright 2008 WorldVistA. Licensed under the terms of the GNU 5 ; General Public License See attached copy of the License. 6 ; 7 ; This program is free software; you can redistribute it and/or modify 8 ; it under the terms of the GNU General Public License as published by 9 ; the Free Software Foundation; either version 2 of the License, or 10 ; (at your option) any later version. 11 ; 12 ; This program is distributed in the hope that it will be useful, 13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ; GNU General Public License for more details. 16 ; 17 ; You should have received a copy of the GNU General Public License along 18 ; with this program; if not, write to the Free Software Foundation, Inc., 19 ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 ; 21 W "NO ENTRY FROM TOP",! 22 Q 23 ; 24 24 EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 25 ; 26 ; MINXML is the Input XML Template, passed by name 27 ; DFN is Patient IEN (by Value) 28 ; OUTXML is the resultant XML (by Name) 29 ; MEDCOUNT is the current count of extracted meds, passed by Reference 30 ; 31 ; MEDS is return array from RPC. 32 ; MAP is a mapping variable map (store result) for each med 33 ; MED is holds each array element from MEDS, one medicine 34 ; 35 ; PEN^PSO5241 is a Pharmacy Re-Enginnering (PRE) API to get Pending 36 ; meds data available. 37 ; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf 38 ; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS). 39 ; File for pending meds is 52.41 40 ; Unfortuantely, API does not supply us with any useful info beyond 41 ; the IEN in 52.41, and the Med Name, and route. 42 ; So, most of the info is going to get pulled from 52.41. 43 N MEDS,MAP 44 K ^TMP($J,"CCDCCR") ; PLEASE DON'T KILL ALL OF ^TMP($J) HERE!!!! 45 D PEN^PSO5241(DFN,"CCDCCR") 46 M MEDS=^TMP($J,"CCDCCR",DFN) 47 ; @(0) contains the number of meds or -1^NO DATA FOUND 48 ; If it is -1, we quit. 49 I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT 50 ZWRITE:$G(DEBUG) MEDS 51 N RXIEN S RXIEN=0 52 N MEDFIRST S MEDFIRST=1 ; FLAG FOR FIRST MED IN THIS SECTION FOR MERGING 53 F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="B" D ; FOR EACH MEDICATION IN THE LIST 54 . I $$GET1^DIQ(52.41,RXIEN,2,"I")="RF" QUIT ; Dont' want refill request as a "pending" order 55 . S MEDCOUNT=MEDCOUNT+1 56 . I DEBUG W "RXIEN IS ",RXIEN,! 57 . S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCOUNT)) 58 . ; K @MAP DON'T KILL MAP HERE, IT IS DONE IN C0CMED 59 . I DEBUG W "MAP= ",MAP,! 60 . N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM 61 . S @MAP@("MEDOBJECTID")="MED_PENDING"_MEDCOUNT ; MEDCOUNT FOR ID 62 . ; S @MAP@("MEDOBJECTID")="MED_PENDING"_MED(.01) ;Pending IEN 63 . S @MAP@("MEDISSUEDATETXT")="Issue Date" 64 . ; Field 6 is "Effective date", and we pull it in timson format w/ I 65 . S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($$GET1^DIQ(52.41,RXIEN,6,"I"),"DT") 66 . ; Med never filled; next 4 fields are not applicable. 67 . S @MAP@("MEDLASTFILLDATETXT")="" 68 . S @MAP@("MEDLASTFILLDATE")="" 69 . S @MAP@("MEDRXNOTXT")="" 70 . S @MAP@("MEDRXNO")="" 71 . S @MAP@("MEDTYPETEXT")="Medication" 72 . S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses 73 . S @MAP@("MEDSTATUSTEXT")="On Hold" ; nearest status for pending meds 74 . S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52.41,RXIEN,5,"I") 75 . S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(11),U,2) 76 . ; NDC not supplied in API, but is rather trivial to obtain 77 . ; MED(11) piece 1 has the IEN of the drug (file 50) 78 . ; IEN is field 31 in the drug file. 79 . ; 80 . ; MEDIEN (node 11 in the returned output) might not necessarily be defined 81 . ; It is not defined when a dose in not chosen in CPRS. There is a long 82 . ; series of fields that depend on it. We will use If and Else to deal 83 . ; with that 84 . N MEDIEN S MEDIEN=$P(MED(11),U) 85 . I +MEDIEN>0 D ; start of if/else block 86 . . ; 12/30/08: I will be using RxNorm for coding... 87 . . ; 176.001 is the file for Concepts; 176.003 is the file for 88 . . ; sources (i.e. for RxNorm Version) 89 . . ; 90 . . ; We need the VUID first for the National Drug File entry first 91 . . ; We get the VUID of the drug, by looking up the VA Product entry 92 . . ; (file 50.68) using the call NDF^PSS50, returned in node 22. 93 . . ; Field 99.99 is the VUID. 94 . . ; 95 . . ; We use the VUID to look up the RxNorm in file 176.001; same idea. 96 . . ; Get IEN first using $$FIND1^DIC, then get the RxNorm number by 97 . . ; $$GET1^DIQ. 98 . . ; 99 . . ; I get the RxNorm name and version from the RxNorm Sources (file 100 . . ; 176.003), by searching for "RXNORM", then get the data. 101 . . D NDF^PSS50(MEDIEN,,,,,"NDF") 102 . . N NDFDATA M NDFDATA=^TMP($J,"NDF",MEDIEN) 103 . . N NDFIEN S NDFIEN=$P(NDFDATA(20),U) 104 . . N VAPROD S VAPROD=$P(NDFDATA(22),U) 105 . . ; 106 . . ; NDFIEN is not necessarily defined; it won't be if the drug 107 . . ; is not matched to the national drug file (e.g. if the drug is 108 . . ; new on the market, compounded, or is a fake drug [blue pill]. 109 . . ; To protect against failure, I will put an if/else block 110 . . N VUID,RXNIEN,RXNORM,SRCIEN,RXNNAME,RXNVER 111 . . I NDFIEN,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet. 112 . . . S VUID=$$GET1^DIQ(50.68,VAPROD,99.99) 113 . . . S RXNIEN=$$FIND1^DIC(176.001,,,VUID,"VUID") 114 . . . S RXNORM=$$GET1^DIQ(176.001,RXNIEN,.01) 115 . . . S SRCIEN=$$FIND1^DIC(176.003,,"B","RXNORM") 116 . . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6) 117 . . . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7) 118 . . ; 119 . . E S (RXNORM,RXNNAME,RXNVER)="" 120 . . ; End if/else block 121 . . S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM 122 . . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME 123 . . S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER 124 . . ; 125 . . S @MAP@("MEDBRANDNAMETEXT")="" 126 . . D DOSE^PSS50(MEDIEN,,,,,"DOSE") 127 . . N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN) 128 . . S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901) 129 . . S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2) 130 . . ; Units, concentration, etc, come from another call 131 . . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit 132 . . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters 133 . . ; NDF Entry IEN, and VA Product Name 134 . . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT") 135 . . ; Documented in the same manual; executed above. 136 . . N CONCDATA 137 . . ; If a drug was not matched to NDF, then the NDFIEN is gonna be "" 138 . . ; and this will crash the call. So... 139 . . I NDFIEN="" S CONCDATA="" 140 . . E S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD) 141 . . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1) 142 . . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3) 143 . . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4) 144 . . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52.41,RXIEN,12) 145 . . ; Oddly, there is no easy place to find the dispense unit. 146 . . ; It's not included in the original call, so we have to go to the drug file. 147 . . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT") 148 . . ; Node 14.5 is the Dispense Unit 149 . . D DATA^PSS50(MEDIEN,,,,,"QTY") 150 . . N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN) 151 . . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5) 152 . E D 153 . . S @MAP@("MEDPRODUCTNAMECODEVALUE")="" 154 . . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="" 155 . . S @MAP@("MEDPRODUCTNAMECODEVERSION")="" 156 . . S @MAP@("MEDBRANDNAMETEXT")="" 157 . . S @MAP@("MEDSTRENGTHVALUE")="" 158 . . S @MAP@("MEDSTRENGTHUNIT")="" 159 . . S @MAP@("MEDFORMTEXT")="" 160 . . S @MAP@("MEDCONCVALUE")="" 161 . . S @MAP@("MEDCONCUNIT")="" 162 . . S @MAP@("MEDSIZETEXT")="" 163 . . S @MAP@("MEDQUANTITYVALUE")="" 164 . . S @MAP@("MEDQUANTITYUNIT")="" 165 . ; end of if/else block 166 . ; 167 . ; --- START OF DIRECTIONS --- 168 . ; Sig data is not in any API. We obtain it using the IEN from 169 . ; the PEN API to file 52.41. It's in field 3, which is a multiple. 170 . ; I will be using FM call GETS^DIQ(FILE,IENS,FIELD,FLAGS,TARGET_ROOT) 171 . K FMSIG ; it's passed via the symbol table, so remove any leftovers from last call 172 . D GETS^DIQ(52.41,RXIEN,"3*",,"FMSIG") 173 . N FMSIGNUM S FMSIGNUM=0 ; Sigline number in fileman. 174 . ; FMSIGNUM gets outputted as "IEN,RXIEN,". 175 . ; DIRNUM will be first piece for IEN. 176 . ; DIRNUM is the proper Sigline numer. 177 . ; SIGDATA is the simplfied array. Subscripts are really field numbers 178 . ; in subfile 52.413. 179 . N DIRCNT S DIRCNT=0 ; COUNT OF DIRECTIONS 180 . F S FMSIGNUM=$O(FMSIG(52.413,FMSIGNUM)) Q:FMSIGNUM="" D 181 . . N DIRNUM S DIRNUM=$P(FMSIGNUM,",") 182 . . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT 183 . . N SIGDATA M SIGDATA=FMSIG(52.413,FMSIGNUM) 184 . . ; If this is an order for a refill; it's not really a new order; move on to next 185 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components. 186 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05. 187 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=SIGDATA(13) 188 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=SIGDATA(8) 189 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT") 190 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient 191 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient 192 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient 193 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=SIGDATA(10) 194 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=SIGDATA(1) 195 . . ; Invervals... again another call. 196 . . ; The schedule is a free text field 197 . . ; However, it gets translated by a call to the administration 198 . . ; schedule file to see if that schedule exists. 199 . . ; That's the same thing I am going to do. 200 . . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ). 201 . . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO-- 202 . . ; I looked), PSSFT is the name, 203 . . ; and list is the ^TMP name to store the data in. 204 . . ; Also, freqency may have "PRN" in it, so strip that out 205 . . N FREQ S FREQ=SIGDATA(1) 206 . . I FREQ["PRN" S FREQ=$E(FREQ,1,$F(FREQ,"PRN")-5) ; 5 for $L("PRN") + 1 + sp 207 . . D AP^PSS51P1("PSJ",FREQ,,,"SCHEDULE") 208 . . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE") 209 . . N INTERVAL 210 . . I $P(SCHEDATA(0),U)=-1 S INTERVAL="" 211 . . E D 212 . . . N SUB S SUB=$O(SCHEDATA(0)) 213 . . . S INTERVAL=SCHEDATA(SUB,2) 214 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL 215 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute" 216 . . ; Duration comes as M2,H2,D2,W2,L2 for 2 minutes,hours,days,weeks,months 217 . . N DUR S DUR=SIGDATA(2) 218 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$E(DUR,2,$L(DUR)) 219 . . N DURUNIT S DURUNIT=$E(DUR) 220 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"") 221 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=SIGDATA(1)["PRN" 222 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")="" 223 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")="" 224 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")="" 225 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")="" 226 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")="" 227 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")="" 228 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")="" 229 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" ; Vista doesn't have that field 230 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM 231 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=SIGDATA(6) 232 . ; 233 . ; --- END OF DIRECTIONS --- 234 . ; 235 . ; S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105" 236 . S @MAP@("MEDPTINSTRUCTIONS")=$G(^PSRX(RXIEN,"PI",1,0)) ;GPL 237 . ; W @MAP@("MEDPTINSTRUCTIONS"),! 238 . ; S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9" 239 . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=$G(^PSRX(RXIEN,"SIG1",1,0)) ;GPL 240 . ; W @MAP@("MEDFULLFILLMENTINSTRUCTIONS"),! 241 . S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13) 242 . N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED")) 243 . K @RESULT 244 . D MAP^C0CXPATH(MINXML,MAP,RESULT) 245 . ; D PARY^C0CXPATH(RESULT) 246 . ; MAPPING DIRECTIONS 247 . N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE 248 . N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT 249 . D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1) 250 . D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions") 251 . ; N MDZ1,MDZNA 252 . I DIRCNT>0 D ; IF THERE ARE DIRCTIONS 253 . . F MDZ1=1:1:DIRCNT D ; FOR EACH DIRECTION 254 . . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",MDZ1)) 255 . . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2) 256 . . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication") 257 . I MEDFIRST D ; 258 . . S MEDFIRST=0 ; RESET FIRST FLAG 259 . . D CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy 260 . D:'MEDFIRST INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER FIRST, INSERT INNER XML 261 N MEDTMP,MEDI 262 D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS 263 I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ 264 . W "Pending Medication MISSING ",! 265 . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),! 266 Q 267 ; -
ccr/trunk/p/C0CMED3.m
r421 r508 1 C0CMED3 2 ;; 0.1;CCDCCR;;;1 C0CMED3 ; WV/CCDCCR/SMH - Meds: Non-VA/Outside Meds for Vista 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;;Last Modified: Sun Jan 11 05:45:03 UTC 2009 4 4 ; Copyright 2009 WorldVistA. Licensed under the terms of the GNU … … 22 22 Q 23 23 ; 24 EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) 24 EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; Extract medications into provided xml template 25 25 ; 26 26 ; MINXML is the Input XML Template, (passed by name) -
ccr/trunk/p/C0CMED6.m
r424 r508 1 1 C0CMED6 ; WV/CCDCCR/SMH - Meds from RPMS: Outpatient Meds;01/10/09 2 ;;0.1;CCDCCR;;JUL 16,2008;3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2 ;;1.0;C0C;;May 19, 2009; 3 ; Copyright 2008 WorldVistA. Licensed under the terms of the GNU 4 ; General Public License See attached copy of the License. 5 ; 6 ; This program is free software; you can redistribute it and/or modify 7 ; it under the terms of the GNU General Public License as published by 8 ; the Free Software Foundation; either version 2 of the License, or 9 ; (at your option) any later version. 10 ; 11 ; This program is distributed in the hope that it will be useful, 12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 ; GNU General Public License for more details. 15 ; 16 ; You should have received a copy of the GNU General Public License along 17 ; with this program; if not, write to the Free Software Foundation, Inc., 18 ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 ; 20 W "NO ENTRY FROM TOP",! 21 Q 22 ; 23 23 EXTRACT(MINXML,DFN,OUTXML,FLAGS) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 24 ; 25 ; MINXML and OUTXML are passed by name so globals can be used 26 ; MINXML will contain only the medications skeleton of the overall template 27 ; FLAGS are: MEDALL(bool)^MEDLIMIT(int)^MEDACTIVE(bool)^MEDPENDING(bool) 28 ; FLAGS are set-up in C0CMED. 29 ; 30 ; MEDS is return array from RPC. 31 ; MAP is a mapping variable map (store result) for each med 32 ; MED is holds each array element from MEDS(J), one medicine 33 ; J is a counter. 34 ; 35 ; GETRXS^BEHORXFN(ARRAYNAME,DFN,DAYS) will be the the API used. 36 ; This API has been developed by Medsphere for IHS for getting 37 ; Medications from RPMS. It has most of what we need. 38 ; API written by Doug Martin when he worked for Medsphere (thanks Doug!) 39 ; -- ARRAYNAME is passed by name (required) 40 ; -- DFN is passed by value (required) 41 ; -- DAYS is passed by value (optional; if not passed defaults to 365) 42 ; 43 ; Return: 44 ; ~Type^PharmID^Drug^InfRate^StopDt^RefRem^TotDose^UnitDose^OrderID 45 ; ^Status^LastFill^Chronic^Issued^Rx #^Provider^ 46 ; Status Reason^DEA Handling 47 ; 48 N MEDS,MEDS1,MAP 49 D GETRXS^BEHORXFN("MEDS1",DFN,$P($P(FLAGS,U,2),"-",2)) ; 2nd piece of FLAGS is # of days to retrieve, which comes in the form "T-360" 50 N ALL S ALL=+FLAGS 51 N ACTIVE S ACTIVE=$P(FLAGS,U,3) 52 N PENDING S PENDING=$P(FLAGS,U,4) 53 S @OUTXML@(0)=0 ;By default, no meds 54 ; If MEDS1 is not defined, then no meds 55 I '$D(MEDS1) QUIT 56 I DEBUG ZWR MEDS1,MINXML 57 N MEDCNT S MEDCNT=0 ; Med Count 58 ; The next line is a super line. It goes through the array return 59 ; and if the first characters are ~OP, it grabs the line. 60 ; This means that line is for a dispensed Outpatient Med. 61 ; That line has the metadata about the med that I need. 62 ; The next lines, however many, are the med and the sig. 63 ; I won't be using those because I have to get the sig parsed exactly. 64 N J S J="" F S J=$O(MEDS1(J)) Q:J="" I $E(MEDS1(J),1,3)="~OP" S MEDCNT=MEDCNT+1 S MEDS(MEDCNT)=MEDS1(J) 65 K MEDS1 66 S MEDCNT="" ; Initialize for $Order 67 F S MEDCNT=$O(MEDS(MEDCNT)) Q:MEDCNT="" D ; for each medication in the list 68 . I 'ALL,ACTIVE,$P(MEDS(MEDCNT),U,10)'="ACTIVE" QUIT 69 . I 'ALL,PENDING,$P(MEDS(MEDCNT),U,10)'="PENDING" QUIT 70 . I DEBUG W "MEDCNT IS ",MEDCNT,! 71 . S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCNT)) 72 . ; K @MAP DO NOT KILL HERE, WAS CLEARED IN C0CMED 73 . I DEBUG W "MAP= ",MAP,! 74 . S @MAP@("MEDOBJECTID")="MED"_MEDCNT ; MEDCNT FOR ID 75 . S @MAP@("MEDISSUEDATETXT")="Issue Date" 76 . S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($P(MEDS(MEDCNT),U,13)) 77 . S @MAP@("MEDLASTFILLDATETXT")="Last Fill Date" 78 . S @MAP@("MEDLASTFILLDATE")=$$FMDTOUTC^C0CUTIL($P(MEDS(MEDCNT),U,11)) 79 . S @MAP@("MEDRXNOTXT")="Prescription Number" 80 . S @MAP@("MEDRXNO")=$P(MEDS(MEDCNT),U,14) 81 . S @MAP@("MEDTYPETEXT")="Medication" 82 . S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses 83 . S @MAP@("MEDSTATUSTEXT")=$P(MEDS(MEDCNT),U,10) 84 . ; Provider only provided in API as text, not DUZ. 85 . ; We need to get DUZ from filman file 52 (Prescription) 86 . ; Field 4; IEN is Piece 2 of Meds stripped of trailing characters. 87 . ; Note that I will use RXIEN several times later 88 . N RXIEN S RXIEN=+$P(MEDS(MEDCNT),U,2) 89 . S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52,RXIEN,4,"I") 90 . S @MAP@("MEDPRODUCTNAMETEXT")=$P(MEDS(MEDCNT),U,3) 91 . ; --- RxNorm Stuff 92 . ; 176.001 is the file for Concepts; 176.003 is the file for 93 . ; sources (i.e. for RxNorm Version) 94 . ; 95 . ; I use 176.001 for the Vista version of this routine (files 1-3) 96 . ; Since IHS does not have VUID's, I will be getting RxNorm codes 97 . ; using NDCs. My specially crafted index (sounds evil) named "NDC" 98 . ; is in file 176.002. The file is called RxNorm NDC to VUID. 99 . ; Except that I don't need the VUID, but it's there if I need it. 100 . ; 101 . ; We obviously need the NDC. That is easily obtained from the prescription. 102 . ; Field 27 in file 52 103 . N NDC S NDC=$$GET1^DIQ(52,RXIEN,27,"I") 104 . ; I discovered that file 176.002 might give you two codes for the NDC 105 . ; One for the Clinical Drug, and one for the ingredient. 106 . ; So the plan is to get the two RxNorm codes, and then find from 107 . ; file 176.001 which one is the Clinical Drug. 108 . ; ... I refactored this into GETRXN 109 . N RXNORM,SRCIEN,RXNNAME,RXNVER 110 . I +NDC,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet. 111 . . S RXNORM=$$GETRXN(NDC) 112 . . S SRCIEN=$$FIND1^DIC(176.003,,,"RXNORM","B") 113 . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6) 114 . . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7) 115 . ; 116 . E S (RXNORM,RXNNAME,RXNVER)="" 117 . ; End if/else block 118 . S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM 119 . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME 120 . S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER 121 . ; --- End RxNorm section 122 . ; 123 . ; Brand name is 52 field 6.5 124 . S @MAP@("MEDBRANDNAMETEXT")=$$GET1^DIQ(52,RXIEN,6.5) 125 . ; 126 . ; Next I need Med Form (tab, cap etc), strength (250mg) 127 . ; concentration for liquids (250mg/mL) 128 . ; Since IHS does not have any of the new calls that 129 . ; Vista has, I will be doing a crosswalk: 130 . ; File 52, field 6 is Drug IEN in file 50 131 . ; File 50, field 22 is VA Product IEN in file 50.68 132 . ; In file 50.68, I will get the following: 133 . ; -- 1: Dosage Form 134 . ; -- 2: Strength 135 . ; -- 3: Units 136 . ; -- 8: Dispense Units 137 . ; -- Conc is 2 concatenated with 3 138 . ; 139 . ; *** If Drug is not matched to NDF, then VA Product will be "" *** 140 . ; 141 . N MEDIEN S MEDIEN=$$GET1^DIQ(52,RXIEN,6,"I") ; Drug IEN in 50 142 . N VAPROD S VAPROD=$$GET1^DIQ(50,MEDIEN,22,"I") ; VA Product in file 50.68 143 . I +VAPROD D 144 . . S @MAP@("MEDSTRENGTHVALUE")=$$GET1^DIQ(50.68,VAPROD,2) 145 . . S @MAP@("MEDSTRENGTHUNIT")=$$GET1^DIQ(50.68,VAPROD,3) 146 . . S @MAP@("MEDFORMTEXT")=$$GET1^DIQ(50.68,VAPROD,1) 147 . . S @MAP@("MEDCONCVALUE")=@MAP@("MEDSTRENGTHVALUE") 148 . . S @MAP@("MEDCONCUNIT")=@MAP@("MEDSTRENGTHUNIT") 149 . E D 150 . . S @MAP@("MEDSTRENGTHVALUE")="" 151 . . S @MAP@("MEDSTRENGTHUNIT")="" 152 . . S @MAP@("MEDFORMTEXT")="" 153 . . S @MAP@("MEDCONCVALUE")="" 154 . . S @MAP@("MEDCONCUNIT")="" 155 . ; End Strengh/Conc stuff 156 . ; 157 . ; Quantity is in the prescription, field 7 158 . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52,RXIEN,7) 159 . ; Dispense unit is in the drug file, field 14.5 160 . S @MAP@("MEDQUANTITYUNIT")=$$GET1^DIQ(50,MEDIEN,14.5) 161 . ; 162 . ; --- START OF DIRECTIONS --- 163 . ; Sig data not in any API :-( Oh yes, you can get the whole thing, but... 164 . ; we want the components. 165 . ; It's in multiple 113 in the Prescription File (52) 166 . ; #.01 DOSAGE ORDERED [1F] "20" 167 . ; #1 DISPENSE UNITS PER DOSE [2N] "1" 168 . ; #2 UNITS [3P:50.607] "MG" 169 . ; #3 NOUN [4F] "TABLET" 170 . ; #4 DURATION [5F] "10D" 171 . ; #5 CONJUNCTION [6S] "AND" 172 . ; #6 ROUTE [7P:51.2] "ORAL" 173 . ; #7 SCHEDULE [8F] "BID" 174 . ; #8 VERB [9F] "TAKE" 175 . ; 176 . ; Will use GETS^DIQ to get fields. 177 . ; Data comes out like this: 178 . ; SAMINS(52.0113,"1,23,",.01)=20 179 . ; SAMINS(52.0113,"1,23,",1)=1 180 . ; SAMINS(52.0113,"1,23,",2)="MG" 181 . ; SAMINS(52.0113,"1,23,",3)="TABLET" 182 . ; SAMINS(52.0113,"1,23,",4)="5D" 183 . ; SAMINS(52.0113,"1,23,",5)="THEN" 184 . ; 185 . N RAWDATA 186 . D GETS^DIQ(52,RXIEN,"113*",,"RAWDATA","DIERR") 187 . D:$D(DIERR) ^%ZTER ; Log if there's an error in retrieving sig field 188 . ; none the less, continue; some parts are retrievable. 189 . N FMSIG M FMSIG=RAWDATA(52.0113) ; Merge into subfile... 190 . K RAWDATA 191 . N FMSIGNUM S FMSIGNUM="" ; Sigline number in fileman. 192 . ; FMSIGNUM gets outputted as "IEN,RXIEN,". 193 . ; DIRCNT is the proper Sigline numer. 194 . ; SIGDATA is the simplfied array. 195 . F S FMSIGNUM=$O(FMSIG(FMSIGNUM)) Q:FMSIGNUM="" D 196 . . N DIRCNT S DIRCNT=$P(FMSIGNUM,",") 197 . . N SIGDATA M SIGDATA=FMSIG(FMSIGNUM) 198 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components. 199 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05. 200 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$G(SIGDATA(8)) 201 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$G(SIGDATA(.01)) 202 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=$G(SIGDATA(2)) 203 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient 204 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient 205 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient 206 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$G(SIGDATA(6)) 207 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$G(SIGDATA(7)) 208 . . ; Invervals... again another call. 209 . . ; In the wisdom of the original programmers, the schedule is a free text field 210 . . ; However, it gets translated by a call to the administration schedule file 211 . . ; to see if that schedule exists. 212 . . ; That's the same thing I am going to do. 213 . . ; Search B index of 51.1 (Admin Schedule) with schedule 214 . . ; First, remove "PRN" if it exists (don't ask, that's how the file 215 . . ; works; I wouldn't do it that way). 216 . . N SCHNOPRN S SCHNOPRN=$G(SIGDATA(7)) 217 . . I SCHNOPRN["PRN" S SCHNOPRN=$E(SCHNOPRN,1,$F(SCHNOPRN,"PRN")-5) 218 . . ; Super call below: 219 . . ; 1=File 51.1 3=Field 2 (Frequency in Minutes) 220 . . ; 4=Packed format, Exact Match 5=Lookup Value 221 . . ; 6=# of entries to return 7=Index 10=Return Array 222 . . ; 223 . . ; I do not account for the fact that two schedules can be 224 . . ; spelled identically (ie duplicate entry). In that case, 225 . . ; I get the first. That's just a bad pharmacy pkg maintainer. 226 . . N C0C515 227 . . D FIND^DIC(51.1,,"@;2","PX",SCHNOPRN,1,"B",,,"C0C515") 228 . . N INTERVAL S INTERVAL="" ; Default 229 . . ; If there are entries found, get it 230 . . I +$G(C0C515("DILIST",0)) S INTERVAL=$P(C0C515("DILIST",1,0),U,2) 231 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL 232 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute" 233 . . ; Duration is 10M minutes, 10H hours, 10D for Days 234 . . ; 10W for weeks, 10L for months. I smell $Select 235 . . ; But we don't need to do that if there isn't a duration 236 . . I +$G(SIGDATA(4)) D 237 . . . N DURUNIT S DURUNIT=$E(SIGDATA(4),$L(SIGDATA(4))) ; get last char 238 . . . N DURTXT S DURTXT=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"Days") 239 . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=+SIGDATA(4) 240 . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=DURTXT 241 . . E D 242 . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")="" 243 . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")="" 244 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$G(SIGDATA(4))["PRN" 245 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")="" ; when avail 246 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")="" 247 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")="" 248 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")="" 249 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")="" 250 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")="" 251 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")="" 252 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" ; not stored 253 . . ; Another confusing line; I am pretty bad: 254 . . ; If there is another entry in the FMSIG array (i.e. another line 255 . . ; in the sig), set the direction count indicator. 256 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")="" ; Default 257 . . S:+$O(FMSIG(FMSIGNUM)) @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRCNT 258 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$G(SIGDATA(5)) 259 . ; 260 . ; --- END OF DIRECTIONS --- 261 . ; 262 . ; Med instructions is a WP field, thus the acrobatics 263 . ; Notice buffer overflow protection set at 10,000 chars 264 . ; -- 1. Med Patient Instructions 265 . N MEDPTIN1 S MEDPTIN1=$$GET1^DIQ(52,RXIEN,115,,"MEDPTIN1") 266 . N MEDPTIN2,J S (MEDPTIN2,J)="" 267 . I $L(MEDPTIN1) F S J=$O(@MEDPTIN1@(J)) Q:J="" Q:$L(MEDPTIN2)>10000 S MEDPTIN2=MEDPTIN2_@MEDPTIN1@(J)_" " 268 . S @MAP@("MEDPTINSTRUCTIONS")=MEDPTIN2 269 . K J 270 . ; -- 2. Med Provider Instructions 271 . N MEDPVIN1 S MEDPVIN1=$$GET1^DIQ(52,RXIEN,39,,"MEDPVIN1") 272 . N MEDPVIN2,J S (MEDPVIN2,J)="" 273 . I $L(MEDPVIN1) F S J=$O(@MEDPVIN1@(J)) Q:J="" Q:$L(MEDPVIN2)>10000 S MEDPVIN2=MEDPVIN2_@MEDPVIN1@(J)_" " 274 . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=MEDPVIN2 275 . ; 276 . ; Remaining refills 277 . S @MAP@("MEDRFNO")=$P(MEDS(MEDCNT),U,6) 278 . ; ------ END OF MAPPING 279 . ; 280 . ; ------ BEGIN XML INSERTION 281 . N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED")) 282 . K @RESULT 283 . D MAP^C0CXPATH(MINXML,MAP,RESULT) 284 . ; D PARY^C0CXPATH(RESULT) 285 . ; MAPPING DIRECTIONS 286 . N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE 287 . N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT 288 . D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1) 289 . D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions") 290 . ; N MDZ1,MDZNA 291 . N DIRCNT S DIRCNT="" 292 . I +$O(@MAP@("M","DIRECTIONS",DIRCNT)) D ; IF THERE ARE DIRCTIONS 293 . . F DIRCNT=$O(@MAP@("M","DIRECTIONS",DIRCNT)) D ; FOR EACH DIRECTION 294 . . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",DIRCNT)) 295 . . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2) 296 . . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication") 297 . D:MEDCNT=1 CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy 298 . D:MEDCNT>1 INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML 299 N MEDTMP,MEDI 300 D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS 301 I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ 302 . W "MEDICATION MISSING ",! 303 . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),! 304 Q 305 ; 306 306 GETRXN(NDC) ; Extrinsic Function; PUBLIC; NDC to RxNorm 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 307 ;; Get RxNorm Concept Number for a Given NDC 308 ; 309 S NDC=$TR(NDC,"-") ; Remove dashes 310 N RXNORM,C0CZRXN,DIERR 311 D FIND^DIC(176.002,,"@;.01","PX",NDC,"*","NDC",,,"C0CZRXN","DIERR") 312 I $D(DIERR) D ^%ZTER BREAK 313 S RXNORM(0)=+C0CZRXN("DILIST",0) ; RxNorm(0) will be # of entries 314 N I S I=0 315 F S I=$O(C0CZRXN("DILIST",I)) Q:I="" S RXNORM(I)=$P(C0CZRXN("DILIST",I,0),U,2) 316 ; At this point, RxNorm(0) is # of entries; RxNorm(1...) are the entries 317 ; If RxNorm(0) is 1, then we only have one entry, and that's it. 318 I RXNORM(0)=1 QUIT RXNORM(1) ; RETURN RXNORM(1) 319 ; Otherwise, we need to find out which one is the semantic 320 ; clinical drug. I built an index on 176.001 (RxNorm Concepts) 321 ; for that purpose. 322 I RXNORM(0)>1 D 323 . S I=0 324 . F S I=$O(RXNORM(I)) Q:I="" D Q:$G(RXNORM) 325 . . N RXNIEN S RXNIEN=$$FIND1^DIC(176.001,,,RXNORM(I),"SCD") 326 . . I +$G(RXNIEN)=0 QUIT ; try the next entry... 327 . . E S RXNORM=RXNORM(I) QUIT ; We found the right code 328 QUIT +$G(RXNORM) ; RETURN RXNORM; if we couldn't find a clnical drug, return with 0 329 -
ccr/trunk/p/C0CPARMS.m
r435 r508 1 1 C0CPARMS ; CCDCCR/GPL - CCR/CCD PARAMETER PROCESSING ; 1/29/09 2 ;; 0.3;CCDCCR;nopatch;noreleasedate2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008 WorldVistA. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. -
ccr/trunk/p/C0CPROBS.m
r396 r508 1 C0CPROBS 2 ;; 0.1;CCDCCR;nopatch;noreleasedate;Build 71 C0CPROBS ; CCDCCR/GPL - CCR/CCD PROCESSING FOR PROBLEMS ; 6/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 22 22 ; PROCESS THE PROBLEMS SECTION OF THE CCR 23 23 ; 24 EXTRACT(IPXML,DFN,OUTXML) 24 EXTRACT(IPXML,DFN,OUTXML) ; EXTRACT PROBLEMS INTO PROVIDED XML TEMPLATE 25 25 ; 26 26 ; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED -
ccr/trunk/p/C0CRIMA.m
r437 r508 1 C0CRIMA 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CRIMA ; CCDCCR/GPL - RIM REPORT ROUTINES; 6/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota. 4 4 ;Licensed under the terms of the GNU General Public License. … … 37 37 ; 38 38 ; 39 ANALYZE(BEGDFN,DFNCNT,APARMS) 39 ANALYZE(BEGDFN,DFNCNT,APARMS) ; RIM COHERANCE ANALYSIS ROUTINE 40 40 ; BEGINS AT BEGDFN AND GOES FOR DFNCNT PATIENTS 41 41 ; TO RESUME AT NEXT PATIENT, USE BEGDFN="" … … 108 108 Q 109 109 ; 110 SETATTR(SDFN) 110 SETATTR(SDFN) ; SET ATTRIBUTES BASED ON VARS 111 111 N SBASE,SATTR 112 112 S SBASE=$NA(@RIMBASE@("VARS",SDFN)) … … 150 150 Q SATTR 151 151 ; 152 RESET 152 RESET ; KILL RESUME INDICATOR TO START OVER. ALSO KILL RIM TMP VALUES 153 153 K ^TMP("C0CRIM","RESUME") 154 154 K ^TMP("C0CRIM") 155 155 Q 156 156 ; 157 CLIST 157 CLIST ; LIST THE CATEGORIES 158 158 ; 159 159 I '$D(RIMBASE) D ASETUP ; FOR COMMAND LINE CALLS … … 169 169 Q 170 170 ; 171 CPUSH(CATRTN,CBASE,CTBL,CDFN,CATTR) 171 CPUSH(CATRTN,CBASE,CTBL,CDFN,CATTR) ; ADD PATIENTS TO CATEGORIES 172 172 ; AND PASS BACK THE NAME OF THE CATEGORY TO WHICH THE PATIENT 173 173 ; WAS ADDED IN CATRTN, WHICH IS PASSED BY REFERENCE … … 205 205 Q 206 206 ; 207 CHKSUM(CKDFN) 207 CHKSUM(CKDFN) ; DOES A CHECKSUM AND STORES IT IN MUMPS GLOBALS 208 208 ; 209 209 S C0CCKB=$NA(^TMP("C0CRIM","CHKSUM")) ;CHECKSUM BASE … … 230 230 Q CHKR 231 231 ; 232 CCOUNT 232 CCOUNT ; RECOUNT THE CATEGORIES.. USE IN CASE OF RESTART OF ANALYZE 233 233 ; 234 234 I '$D(RIMBASE) D ASETUP ; FOR COMMAND LINE CALLS … … 252 252 Q 253 253 ; 254 CNTLST(INLST) 254 CNTLST(INLST) ; RETURNS THE NUMBER OF ELEMENTS IN THE LIST 255 255 ; INLST IS PASSED BY NAME 256 256 N ZI,ZDX,ZCOUNT … … 264 264 Q ZCOUNT 265 265 ; 266 XCPAT(CPATCAT,CPATPARM) 266 XCPAT(CPATCAT,CPATPARM) ; EXPORT TO FILE ALL PATIENTS IN CATEGORY CPATCAT 267 267 ; 268 268 I '$D(CPATPARM) S CPATPARM="" … … 276 276 Q 277 277 ; 278 CPAT(CPATCAT) 278 CPAT(CPATCAT) ; SHOW PATIENT DFNS FOR A CATEGORY CPATCAT 279 279 ; 280 280 I '$D(RIMBASE) D ASETUP ; FOR COMMAND LINE CALLS … … 292 292 Q 293 293 ; 294 PATC(DFN) 294 PATC(DFN) ; DISPLAY THE CATEGORY FOR THIS PATIENT 295 295 ; 296 296 N ATTR S ATTR="" … … 305 305 Q 306 306 ; 307 APUSH(AMAP,AVAL) 307 APUSH(AMAP,AVAL) ; ADD AVAL TO ATTRIBUTE MAP AMAP (AMAP PASSED BY NAME) 308 308 ; AMAP IS FORMED FOR ARRAY ACCESS: AMAP(0) IS THE COUNT 309 309 ; AND AMAP(N)=AVAL IS THE NTH AVAL … … 320 320 Q 321 321 ; 322 ASETUP 322 ASETUP ; SET UP GLOBALS AND VARS RIMBASE AND RIMTBL 323 323 I '$D(RIMBASE) S RIMBASE=$NA(^TMP("C0CRIM")) 324 324 I '$D(@RIMBASE) S @RIMBASE="" … … 327 327 Q 328 328 ; 329 AINIT 329 AINIT ; INITIALIZE ATTRIBUTE TABLE 330 330 I '$D(RIMBASE) D ASETUP ; FOR COMMAND LINE CALLS 331 331 K @RIMTBL … … 358 358 Q 359 359 ; 360 APOST(PRSLT,PTBL,PVAL) 360 APOST(PRSLT,PTBL,PVAL) ; POST AN ATTRIBUTE PVAL TO PRSLT USING PTBL 361 361 ; PSRLT AND PTBL ARE PASSED BY NAME. PVAL IS A STRING 362 362 ; PTBL IS THE NAME OF A TABLE IN @RIMBASE@("TABLES") - "RIMTBL"=ALL VALUES … … 369 369 S $P(@PRSLT,U,@USETBL@(PVAL))=PVAL 370 370 Q 371 GETPA(RTN,DFN,ISEC,IVAR) 371 GETPA(RTN,DFN,ISEC,IVAR) ; RETURNS ARRAY OF RIM VARIABLES FOR PATIENT DFN 372 372 ; EXAMPLE: D GETPA(.RT,2,"MEDS","MEDSSTATUSTEXT") 373 373 ; RETURNS AN ARRAY RT OF VALUES OF MEDSTATUSTEXT FOR PATIENT 2 IN P2 … … 392 392 Q 393 393 ; 394 PATD(DFN,ISEC,IVAR) 394 PATD(DFN,ISEC,IVAR) ; DISPLAY FOR PATIENT DFN THE VARIABLE IVAR 395 395 ; 396 396 N ZR … … 400 400 Q 401 401 ; 402 CAGET(RTN,IATTR) 402 CAGET(RTN,IATTR) ; 403 403 ; GETPA LOOKS AT RIMTBL TO FIND PATIENTS WITH ATTRIBUTE IATTR 404 404 ; IT DOES NOT SEARCH ALL PATIENTS, ONLY THE ONES WITH THE ATTRIBUTE … … 406 406 Q 407 407 ; 408 PCLST(LSTRTN,IATTR) 408 PCLST(LSTRTN,IATTR) ; RETURNS ARRAY OF PATIENTS WITH ATTRIBUTE IATTR 409 409 ; 410 410 I '$D(RIMBASE) D AINIT ; INITIALIZE GLOBAL NAMES AND TABLES … … 431 431 Q 432 432 ; 433 DCPAT(CATTR) 433 DCPAT(CATTR) ; DISPLAY LIST OF PATIENTS WITH ATTRIBUTE CATTR 434 434 ; 435 435 N ZR … … 442 442 Q 443 443 ; 444 RPCGV(RTN,DFN,WHICH) 444 RPCGV(RTN,DFN,WHICH) ; RPC GET VARS 445 445 ; RETURNS IN RTN (PASSED BY REFERENCE) THE VARS AND VALUES 446 446 ; FOUND AT INARY RTN(X)="VAR^VALUE" RTN(0) IS THE COUNT … … 460 460 Q 461 461 ; 462 ZGVWRK(ZWHICH) 462 ZGVWRK(ZWHICH) ; DO ONE SECTION FOR RPCGV 463 463 ; 464 464 N ZZGN ; NAME FOR SECTION VARIABLES … … 477 477 Q 478 478 ; 479 DPATV(DFN,IWHICH) 479 DPATV(DFN,IWHICH) ; DISPLAY VARS FOR PATIENT DFN THAT ARE MAINTAINED IN C0CRIM 480 480 ; ALONG WITH SAMPLE VALUES. 481 481 ; IWHICH IS "ALL","MEDS","VITALS","PROBLEMS","ALERTS","RESULTS","HEADER" … … 488 488 Q 489 489 ; 490 RIM2RNF(R2RTN,DFN,RWHICH) 490 RIM2RNF(R2RTN,DFN,RWHICH) ; CONVERTS RIM VARIABLES TO RNF2 FORMAT 491 491 ; RETURN IN R2RTN, WHICH IS PASSED BY NAME 492 492 ; RWHICH IS RIM SECTION TO RETURN, DEFAULTS TO "ALL" … … 514 514 Q 515 515 ; 516 RIM2CSV(DFN) 516 RIM2CSV(DFN) ; WRITE THE RIM VARIABLES FOR A PATIENT TO A CSV FILE 517 517 ; 518 518 N R2CTMP,R2CARY -
ccr/trunk/p/C0CRNF.m
r431 r508 1 C0CRNF 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CRNF ; CCDCCR/GPL - Reference Name Format (RNF) utilities; 12/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2009 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 22 22 Q 23 23 ; 24 FIELDS(C0CFRTN,C0CF) 24 FIELDS(C0CFRTN,C0CF) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF, 25 25 ; C0CFRTN IS PASSED BY NAME, C0CF IS PASSED BY VALUE 26 26 ; … … 44 44 Q 45 45 ; 46 GETNOLD(GRTN,GFILE,GIEN,GNN) 46 GETNOLD(GRTN,GFILE,GIEN,GNN) ; GET FIELDS FOR ACCESS BY NAME 47 47 ; GRTN IS PASSED BY NAME 48 48 ; … … 70 70 Q 71 71 ; 72 GETN(GRTN,GFILE,GREF,GNDX,GNN) 72 GETN(GRTN,GFILE,GREF,GNDX,GNN) ; GET BY NAME ; RETURN A FIELD VALUE MAP 73 73 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1 74 74 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL … … 134 134 Q 135 135 ; 136 GETN1(GRTN,GFILE,GREF,GNDX,GNN) 136 GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP 137 137 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1 138 138 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL … … 198 198 Q 199 199 ; 200 GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN) 200 GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES 201 201 ; GARTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP 202 202 ; .. FIELD MAP @GARTN@("F","FIELDNAME")="FILE;FIELD#" … … 232 232 Q 233 233 ; 234 ADDNV(GNV,GNVN,GNVF,GNVV) 234 ADDNV(GNV,GNVN,GNVF,GNVV) ; CREATE AN ELEMENT OF THE MATRIX 235 235 ; 236 236 S @GNV@("F",GNVF)=$P(GNVV,"^",1)_"^"_$P(GNVV,"^",2) ;NAME=FILE^FIELD# … … 238 238 Q 239 239 ; 240 RNF2CSV(RNRTN,RNIN,RNSTY) 240 RNF2CSV(RNRTN,RNIN,RNSTY) ;CONVERTS AN RFN2 GLOBAL TO A CSV FORMAT 241 241 ; READY TO WRITE FOR USE WITH EXCEL @RNRTN@(0) IS NUMBER OF LINES 242 242 ; RNSTY IS STYLE OF THE OUTPUT - … … 251 251 Q 252 252 ; 253 NV(RNRTN,RNIN) 253 NV(RNRTN,RNIN) ; 254 254 S RNR=$NA(@RNIN@("F")) 255 255 S RNC=$NA(@RNIN@("V")) … … 273 273 Q 274 274 ; 275 VN(RNRTN,RNIN) 275 VN(RNRTN,RNIN) ; 276 276 S RNR=$NA(@RNIN@("V")) 277 277 S RNC=$NA(@RNIN@("F")) … … 295 295 Q 296 296 ; 297 FILE2CSV(FNUM,FVN) 297 FILE2CSV(FNUM,FVN) ; WRITES OUT A FILEMAN FILE TO CSV 298 298 ; 299 299 ;N G1,G2 … … 308 308 Q 309 309 ; 310 FILEOUT(FOARY,FONAM) 310 FILEOUT(FOARY,FONAM) ; WRITE OUT A FILE 311 311 ; 312 312 W $$OUTPUT^GPLXPATH($NA(@FOARY@(1)),FONAM,^TMP("GPLCCR","ODIR")) 313 313 Q 314 314 ; 315 FILEREF(FNUM) 315 FILEREF(FNUM) ; EXTRINSIC THAT RETURNS A CLOSED ROOT FOR FILE NUMBER FNUM 316 316 ; 317 317 N C0CF … … 321 321 Q C0CF 322 322 ; 323 SKIP 323 SKIP ; 324 324 N TXT,DIERR 325 325 S TXT=$$GET1^DIQ(8925,TIUIEN,"2","","TXT") … … 332 332 Q 333 333 ; 334 ZFILE(ZFN,ZTAB) 334 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED 335 335 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF @ZTAB@(ZFN) 336 336 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA 337 337 I '$D(ZTAB) S ZTAB="C0CA" 338 338 Q $P(@ZTAB@(ZFN),"^",1) 339 ZFIELD(ZFN,ZTAB) 339 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED 340 340 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF @ZTAB@(ZFN) 341 341 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA 342 342 I '$D(ZTAB) S ZTAB="C0CA" 343 343 Q $P(@ZTAB@(ZFN),"^",2) 344 ZVALUE(ZFN,ZTAB) 344 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED 345 345 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF @ZTAB@(ZFN) 346 346 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 348 348 Q $P($G(@ZTAB@(ZFN)),"^",3) 349 349 ; 350 ZVALUEI(ZFN,ZTAB) 350 ZVALUEI(ZFN,ZTAB) ;EXTRINSIC TO RETURN INTERNAL VALUE FOR FIELD NAME PASSED 351 351 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF @ZTAB@(ZFN) 352 352 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA -
ccr/trunk/p/C0CRXN.m
r404 r508 1 C0CRXN 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CRXN ; CCDCCR/GPL - CCR RXN utilities; 12/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2009 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 22 22 Q 23 23 ; 24 EXPAND 24 EXPAND ; MAIN ROUTINE TO CREATE THE C0C RXNORM VUID EXPANSION FILE (176.112) 25 25 ; READ EACH RECORD FROM 176.111 AND USE THE VUID TO LOOK UP THE RXNORM 26 26 ; CODE FROM 176.001 (RXNORM CONCEPTS) … … 83 83 Q 84 84 ; 85 EXP2 85 EXP2 ; ROUTINE TO CREATE 176.113 C0C RXNORM VUID MAPPING DISCREPANCIES FILE 86 86 ; CROSS CHECKS THE NATIONAL DRUG FILE AND THE VA MAPPING FILE AGAINST 87 87 ; THE UMLS RXNORM DATABASE … … 158 158 W "NDF TEXT MISMATCH: ",NDFTCNT,! 159 159 Q 160 CHKNDF 160 CHKNDF ; ROUTINE TO CHECK THE NATIONAL DRUG FILE WITH THE UMLS RXNORM DB 161 161 ; USING THE AVUID INDEX, READS ALL VUID CODES IN ^PSNDF(50.68), 162 162 ; CHECKS TO SEE IF THE CODE IS IN 176.001, AND CREATES A RECORD … … 253 253 W "TEXT MATCHES:",TXTMATCH,! 254 254 Q 255 SETFDA(C0CSN,C0CSV) 255 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN 256 256 ; TO SET TO VALUE C0CSV. 257 257 ; C0CFDA,C0CA,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE … … 263 263 S C0CFDA(C0CSI,"+"_C0CZX_",",C0CSJ)=C0CSV 264 264 Q 265 ZFILE(ZFN,ZTAB) 265 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED 266 266 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN) 267 267 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 271 271 E S ZR="" 272 272 Q ZR 273 ZFIELD(ZFN,ZTAB) 273 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED 274 274 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN) 275 275 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 280 280 Q ZR 281 281 ; 282 ZVALUE(ZFN,ZTAB) 282 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED 283 283 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN) 284 284 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA -
ccr/trunk/p/C0CSUB1.m
r436 r508 1 C0CSUB1 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CSUB1 ; CCDCCR/GPL - CCR SUBSCRIPTION utilities; 12/6/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2009 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 21 21 Q 22 22 ; 23 CHK1(DFN) 23 CHK1(DFN) ; ADD THE CHECKSUM FOR ONE PATIENT 24 24 ; 25 25 S C0CCHK=$NA(^TMP("C0CRIM","CHKSUM")) … … 43 43 Q 44 44 ; 45 SUBALL 45 SUBALL ; SUBSCRIBE ALL PATIENTS IN CCR GLOBALS TO SUBCRIBER 1 46 46 ; 47 47 S C0CGLB=$NA(^TMP("C0CRIM","VARS")) … … 51 51 Q 52 52 ; 53 SUB1(DFN,C0CSS) 53 SUB1(DFN,C0CSS) ; SUBSCRIBE ONE PATIENT TO SUBSCRIBER C0CSS 54 54 ; 55 55 S C0CSF=177.101 ; FILE NUMBER FOR SUBSCRIPTION FILE … … 66 66 Q 67 67 ; 68 UPDIE 68 UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS 69 69 K ZERR 70 70 D CLEAN^DILF … … 77 77 Q 78 78 ; 79 VARPTR(ZVAR,ZTYP) 79 VARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE 80 80 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO 81 81 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO … … 99 99 Q ZVARN 100 100 ; 101 SETFDA(C0CSN,C0CSV) 101 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN 102 102 ; TO SET TO VALUE C0CSV. 103 103 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE … … 109 109 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV 110 110 Q 111 ZFILE(ZFN,ZTAB) 111 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED 112 112 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN) 113 113 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 117 117 E S ZR="" 118 118 Q ZR 119 ZFIELD(ZFN,ZTAB) 119 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED 120 120 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN) 121 121 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA … … 126 126 Q ZR 127 127 ; 128 ZVALUE(ZFN,ZTAB) 128 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED 129 129 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN) 130 130 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA -
ccr/trunk/p/C0CSYS.m
r399 r508 1 C0CSYS 2 ;; 0.1;C0C;;;1 C0CSYS ;WV/C0C/SMH - Routine to Get EHR System Information;6JUL2008 2 ;;1.0;C0C;;May 19, 2009; 3 3 ; Copyright 2008 WorldVistA. Licensed under the terms of the GNU 4 4 ; General Public License See attached copy of the License. … … 27 27 ; So for now, I am hard-coding the values. 28 28 ; 29 SYSNAME() 30 31 32 33 SYSVER() 34 35 36 PTST(DFN) 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 29 SYSNAME() ;Get EHR System Name; PUBLIC; Extrinsic 30 Q:$G(DUZ("AG"))="I" "RPMS" 31 Q "WorldVistA EHR/VOE" 32 ; 33 SYSVER() ;Get EHR System Version; PUBLIC; Extrinsic 34 Q "1.0" 35 ; 36 PTST(DFN) ;TEST TO SEE IF PATIENT MERGED OR A TEST PATIENT 37 ; DFN = IEN of the Patient to be tested 38 ; 1 = Merged or Test Patient 39 ; 0 = Non-test Patient 40 ; 41 I DFN="" Q 0 ; BAD DFN PASSED 42 I $D(^DPT(DFN,-9)) Q 1 ;This patient has been merged 43 I $G(^DPT(DFN,0))="" Q 1 ;Missing zeroth node <---add 44 ; 45 I '$D(CCRTEST) S CCRTEST=1 ; DEFAULT IS THAT WE ARE TESTING 46 I CCRTEST Q 0 ; IF WE ARE TESTING, DON'T REJECT TEST PATIENTS 47 N DIERR,DATA 48 I $$TESTPAT^VADPT(DFN) Q 1 ; QUIT IF IT'S A VA TEST PATIENT 49 S DATA=+$$GET1^DIQ(2,DFN_",",.6,"I") ;Test Patient Indicator 50 ; 1 = Test Patient 51 ; 0 = Non-test Patient 52 I DATA Q DATA 53 S DATA=$$GET1^DIQ(2,DFN_",",.09,"I") ;SSN test 54 D CLEAN^DILF 55 I "Pp"[$E(DATA,$L(DATA),$L(DATA)) Q 0 ;Allow Pseudo SSN 56 I $E(DATA,1,3)="000" Q 1 57 I $E(DATA,1,3)="666" Q 1 58 Q 0 59 ; -
ccr/trunk/p/C0CUNIT.m
r416 r508 1 C0CUNIT 2 ;; 0.1;CCDCCR;nopatch;noreleasedate1 C0CUNIT ; CCDCCR/GPL - Unit Testing Library; 5/07/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 22 22 Q 23 23 ; 24 ZT(ZARY,BAT,TST) 24 ZT(ZARY,BAT,TST) ; private routine to add a test case to the ZARY array 25 25 ; ZARY IS PASSED BY REFERENCE 26 26 ; BAT is a string identifying the test battery … … 45 45 Q 46 46 ; 47 ZLOAD(ZARY,ROUTINE) 47 ZLOAD(ZARY,ROUTINE) ; load tests into ZARY which is passed by reference 48 48 ; ZARY IS PASSED BY NAME 49 49 ; ZARY = name of the root, closed array format (e.g., "^TMP($J)") … … 68 68 Q 69 69 ; 70 ZTEST(ZARY,WHICH) 70 ZTEST(ZARY,WHICH) ; try out the tests using a passed array ZTEST 71 71 N ZI,ZX,ZR,ZP 72 72 S DEBUG=0 … … 104 104 Q 105 105 ; 106 TEST 106 TEST ; RUN ALL THE TEST CASES 107 107 N ZTMP 108 108 D ZLOAD(.ZTMP) … … 115 115 Q 116 116 ; 117 GTSTS(GTZARY,RTN) 117 GTSTS(GTZARY,RTN) ; return an array of test names 118 118 N I,J S I="" S I=$O(GTZARY("TESTS",I)) 119 119 F J=0:0 Q:I="" D … … 122 122 Q 123 123 ; 124 TESTALL(RNM) 124 TESTALL(RNM) ; RUN ALL THE TESTS 125 125 N ZI,J,TZTMP,TSTS,TOTP,TOTF 126 126 S TOTP=0 S TOTF=0 … … 141 141 Q 142 142 ; 143 TLIST(ZARY) 143 TLIST(ZARY) ; LIST ALL THE TESTS 144 144 ; THEY ARE MARKED AS ;;><TESTNAME> IN THE TEST CASES 145 145 ; ZARY IS PASSED BY REFERENCE … … 155 155 Q 156 156 ; 157 MEDS 157 MEDS 158 158 N DEBUG S DEBUG=0 159 159 N DFN S DFN=5685 … … 172 172 D FILEOUT^C0CRNF(OUTXML,"TESTMEDS.xml") 173 173 Q 174 PAT 174 PAT 175 175 D ANALYZE^ARJTXRD("C0CDPT",.OUT) ; Analyze a routine in the directory 176 176 N X,Y -
ccr/trunk/p/C0CUTIL.m
r421 r508 1 1 C0CUTIL ;WV/C0C/SMH - Various Utilites for generating the CCR/CCD;06/15/08 2 ;;0.1;C0C;;Jun 15, 2008;3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2 ;;1.0;C0C;;May 19, 2009; 3 ;Copyright 2008-2009 Sam Habiel & George Lilly. 4 ;Licensed under the terms of the GNU 5 ;General Public License See attached copy of the License. 6 ; 7 ;This program is free software; you can redistribute it and/or modify 8 ;it under the terms of the GNU General Public License as published by 9 ;the Free Software Foundation; either version 2 of the License, or 10 ;(at your option) any later version. 11 ; 12 ;This program is distributed in the hope that it will be useful, 13 ;but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ;GNU General Public License for more details. 16 ; 17 ;You should have received a copy of the GNU General Public License along 18 ;with this program; if not, write to the Free Software Foundation, Inc., 19 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 ; 21 W "No Entry at Top!" 22 Q 23 ; 24 24 FMDTOUTC(DATE,FORMAT) ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrinsic 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 25 ; FORMAT is Format of Date. Can be either D (Day) or DT (Date and Time) 26 ; If not passed, or passed incorrectly, it's assumed that it is D. 27 ; FM Date format is "YYYMMDD.HHMMSS" HHMMSS may not be supplied. 28 ; UTC date is formatted as follows: YYYY-MM-DDThh:mm:ss_offsetfromUTC 29 ; UTC, Year, Month, Day, Hours, Minutes, Seconds, Time offset (obtained from Mailman Site Parameters) 30 N UTC,Y,M,D,H,MM,S,OFF 31 S Y=1700+$E(DATE,1,3) 32 S M=$E(DATE,4,5) 33 S D=$E(DATE,6,7) 34 S H=$E(DATE,9,10) 35 I $L(H)=1 S H="0"_H 36 S MM=$E(DATE,11,12) 37 I $L(MM)=1 S MM="0"_MM 38 S S=$E(DATE,13,14) 39 I $L(S)=1 S S="0"_S 40 S OFF=$$TZ^XLFDT ; See Kernel Manual for documentation. 41 S OFFS=$E(OFF,1,1) 42 S OFF0=$TR(OFF,"+-") 43 S OFF1=$E(OFF0+10000,2,3) 44 S OFF2=$E(OFF0+10000,4,5) 45 S OFF=OFFS_OFF1_":"_OFF2 46 ;S OFF2=$E(OFF,1,2) ; 47 ;S OFF2=$E(100+OFF2,2,3) ; GPL 11/08 CHANGED TO -05:00 FORMAT 48 ;S OFF3=$E(OFF,3,4) ;MINUTES 49 ;S OFF=$S(OFF2="":"00",0:"00",1:OFF2)_"."_$S(OFF3="":"00",1:OFF3) 50 ; If H, MM and S are empty, it means that the FM date didn't supply the time. 51 ; In this case, set H, MM and S to "00" 52 ; S:('$L(H)&'$L(MM)&'$L(S)) (H,MM,S)="00" ; IF ONLY SOME ARE MISSING? 53 S:'$L(H) H="00" 54 S:'$L(MM) MM="00" 55 S:'$L(S) S="00" 56 S UTC=Y_"-"_M_"-"_D_"T"_H_":"_MM_$S(S="":":00",1:":"_S)_OFF ; Skip's code to fix hanging colon if no seconds 57 I $L($G(FORMAT)),FORMAT="DT" Q UTC ; Date with time. 58 E Q $P(UTC,"T") 59 ; 60 60 SORTDT(V1,V2,ORDR) ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 61 ; AS EXTRINSIC ORDR IS 1 OR -1 FOR FORWARD OR REVERSE 62 ; DATE AND TIME ORDER. DEFAULT IS FORWARD 63 ; V2 IS AN ARRAY OF DATES IN FILEMAN FORMAT 64 ; V1 IS RETURNS INDIRECT INDEXES OF V2 IN REVERSE DATE ORDER 65 ; SO V2(V1(X)) WILL RETURN THE DATES IN DATE/TIME ORDER 66 ; THE COUNT OF THE DATES IS RETURNED AS AN EXTRINSIC 67 ; BOTH V1 AND V2 ARE PASSED BY REFERENCE 68 N VSRT ; TEMP FOR HASHING DATES 69 N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2 70 S ZCNT=V2(0) ; COUNTING NUMBER OF DATES 71 F ZI=1:1:ZCNT D ; FOR EACH DATE IN THE ARRAY 72 . I $D(V2(ZI)) D ; IF THE DATE EXISTS 73 . . S ZP1=$P(V2(ZI),".",1) ; THE DATE PIECE 74 . . S ZP2=$P(V2(ZI),".",2) ; THE TIME PIECE 75 . . ; W "DATE: ",ZP1," TIME: ",ZP2,! 76 . . S VSRT(ZP1,ZP2,ZI)=ZI ; INDEX OF DATE, TIME AND COUNT 77 N ZG 78 S ZG=$Q(VSRT("")) 79 F D Q:ZG="" ; 80 . ; W ZG,! 81 . D PUSH^GPLXPATH("V1",@ZG) 82 . S ZG=$Q(@ZG) 83 I ORDR=-1 D ; HAVE TO REVERSE ORDER 84 . N ZG2 85 . F ZI=1:1:V1(0) D ; FOR EACH ELELMENT 86 . . S ZG2(V1(0)-ZI+1)=V1(ZI) ; SET IN REVERSE ORDER 87 . S ZG2(0)=V1(0) 88 . D CP^GPLXPATH("ZG2","V1") ; COPY OVER THE NEW ARRAY 89 Q ZCNT 90 ; 91 91 DA2SNO(RTN,DNAME) ; LOOK UP DRUG ALLERGY CODE IN ^LEX 92 93 94 95 96 97 98 99 100 101 102 103 104 105 92 ; RETURNS AN ARRAY RTN PASSED BY REFERENCE 93 ; THIS ROUTINE CAN BE USED AS AN RPC 94 ; RTN(0) IS THE NUMBER OF ELEMENTS IN THE ARRAY 95 ; RTN(1) IS THE SNOMED CODE FOR THE DRUG ALLERGY 96 ; 97 N LEXIEN 98 I $O(^LEX(757.21,"ADIS",DNAME,""))'="" D ; IEN FOUND FOR THIS DRUG 99 . S LEXIEN=$O(^LEX(757.21,"ADIS",DNAME,"")) ; GET THE IEN IN THE LEXICON 100 . W LEXIEN,! 101 . S RTN(1)=$P(^LEX(757.02,LEXIEN,0),"^",2) ; SNOMED CODE IN P2 102 . S RTN(0)=1 ; ONE THING RETURNED 103 E S RTN(0)=0 ; NOT FOUND 104 Q 105 ; 106 106 DASNO(DANAME) ; PRINTS THE SNOMED CODE FOR ALLERGY TO DRUG DANAME 107 108 109 110 111 112 113 114 107 ; 108 N DARTN 109 D DA2SNO(.DARTN,DANAME) ; CALL THE LOOKUP ROUTINE 110 I DARTN(0)>0 D ; GOT RESULTS 111 . W !,DARTN(1) ;PRINT THE SNOMED CODE 112 E W !,"NOT FOUND",! 113 Q 114 ; 115 115 DASNALL(WHICH) ; ROUTINE TO EXAMINE THE ADIS INDEX IN LEX AND RETRIEVE ALL 116 117 118 119 120 121 122 123 124 116 ; ASSOCIATED SNOMED CODES 117 N DASTMP,DASIEN,DASNO 118 S DASTMP="" 119 F S DASTMP=$O(^LEX(757.21,WHICH,DASTMP)) Q:DASTMP="" D ; NAME OF MED 120 . S DASIEN=$O(^LEX(757.21,WHICH,DASTMP,"")) ; IEN OF MED 121 . S DASNO=$P(^LEX(757.02,DASIEN,0),"^",2) ; SNOMED CODE FOR ENTRY 122 . W DASTMP,"=",DASNO,! ; PRINT IT OUT 123 Q 124 ; 125 125 RPMS() ; Are we running on an RPMS system rather than Vista? 126 126 Q $G(DUZ("AG"))="I" ; If User Agency is Indian Health Service 127 127 VISTA() ; Are we running on Vanilla Vista? 128 128 Q $G(DUZ("AG"))="V" ; If User Agency is VA 129 129 WV() ; Are we running on WorldVista? 130 130 Q $G(DUZ("AG"))="E" ; Code for WV. 131 131 OV() ; Are we running on OpenVista? 132 132 Q $G(DUZ("AG"))="O" ; Code for OpenVista -
ccr/trunk/p/C0CVA200.m
r397 r508 1 C0CVA200 2 ;;0.1;C0C;;JUL 13, 2007;Build 01 C0CVA200 ;WV/C0C/SMH - Routine to get Provider Data;07/13/2008 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008 Sam Habiel. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 17 17 ;with this program; if not, write to the Free Software Foundation, Inc., 18 18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 20 21 22 23 24 25 FAMILY(DUZ) 26 27 28 29 30 31 32 GIVEN(DUZ) 33 34 35 36 37 38 39 MIDDLE(DUZ) 40 41 42 43 44 45 46 SUFFIX(DUZ) 47 48 49 50 51 52 53 TITLE(DUZ) 54 55 56 57 58 59 60 61 NPI(DUZ) 62 63 64 ;IDType^ID^IDDescription65 66 67 68 69 70 71 72 73 SPEC(DUZ) 74 75 76 77 ;in file 200.78 79 80 81 82 83 84 85 ADDTYPE(DUZ) 86 87 88 89 90 ADDLINE1(ADUZ) 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 CITY(ADUZ) 114 115 116 117 118 119 120 121 122 123 124 125 126 STATE(ADUZ) 127 128 129 130 131 132 133 134 135 136 137 138 POSTCODE(ADUZ) 139 140 141 142 143 144 145 146 147 148 149 150 TEL(DUZ) 151 152 153 154 155 156 157 TELTYPE(DUZ) 158 159 160 161 162 EMAIL(DUZ) 163 164 165 166 167 168 19 Q 20 ; This routine uses Kernel APIs and Direct Global Access to get 21 ; Proivder Data from File 200. 22 ; 23 ; The Global is VA(200,*) 24 ; 25 FAMILY(DUZ) ; Get Family Name; PUBLIC; EXTRINSIC 26 ; INPUT: DUZ (i.e. File 200 IEN) ByVal 27 ; OUTPUT: String 28 N NAME S NAME=$P(^VA(200,DUZ,0),U) 29 D NAMECOMP^XLFNAME(.NAME) 30 Q NAME("FAMILY") 31 ; 32 GIVEN(DUZ) ; Get Given Name; PUBLIC; EXTRINSIC 33 ; INPUT: DUZ ByVal 34 ; OUTPUT: String 35 N NAME S NAME=$P(^VA(200,DUZ,0),U) 36 D NAMECOMP^XLFNAME(.NAME) 37 Q NAME("GIVEN") 38 ; 39 MIDDLE(DUZ) ; Get Middle Name, PUBLIC; EXTRINSIC 40 ; INPUT: DUZ ByVal 41 ; OUTPUT: String 42 N NAME S NAME=$P(^VA(200,DUZ,0),U) 43 D NAMECOMP^XLFNAME(.NAME) 44 Q NAME("MIDDLE") 45 ; 46 SUFFIX(DUZ) ; Get Suffix Name, PUBLIC; EXTRINSIC 47 ; INPUT: DUZ ByVal 48 ; OUTPUT: String 49 N NAME S NAME=$P(^VA(200,DUZ,0),U) 50 D NAMECOMP^XLFNAME(.NAME) 51 Q NAME("SUFFIX") 52 ; 53 TITLE(DUZ) ; Get Title for Proivder, PUBLIC; EXTRINSIC 54 ; INPUT: DUZ ByVal 55 ; OUTPUT: String 56 ; Gets External Value of Title field in New Person File. 57 ; It's actually a pointer to file 3.1 58 ; 200=New Person File; 8 is Title Field 59 Q $$GET1^DIQ(200,DUZ_",",8) 60 ; 61 NPI(DUZ) ; Get NPI Number, PUBLIC; EXTRINSIC 62 ; INPUT: DUZ ByVal 63 ; OUTPUT: Delimited String in format: 64 ; IDType^ID^IDDescription 65 ; If the NPI doesn't exist, "" is returned. 66 ; This routine uses a call documented in the Kernel dev guide 67 ; This call returns as "NPI^TimeEntered^ActiveInactive" 68 ; It returns -1 for NPI if NPI doesn't exist. 69 N NPI S NPI=$P($$NPI^XUSNPI("Individual_ID",DUZ),U) 70 Q:NPI=-1 "" 71 Q "NPI^"_NPI_"^HHS" 72 ; 73 SPEC(DUZ) ; Get Provider Specialty, PUBLIC; EXTRINSIC 74 ; INPUT: DUZ ByVal 75 ; OUTPUT: String: ProviderType/Specialty/Subspecialty OR "" 76 ; Uses a Kernel API. Returns -1 if a specialty is not specified 77 ; in file 200. 78 ; Otherwise, returns IEN^Profession^Specialty^Subspecialty^Effect date^Expired date^VA code 79 N STR S STR=$$GET^XUA4A72(DUZ) 80 Q:+STR<0 "" 81 ; Sometimes we have 3 pieces, or 2. Deal with that. 82 Q:$L($P(STR,U,4)) $P(STR,U,2)_"-"_$P(STR,U,3)_"-"_$P(STR,U,4) 83 Q $P(STR,U,2)_"-"_$P(STR,U,3) 84 ; 85 ADDTYPE(DUZ) ; Get Address Type, PUBLIC; EXTRINSIC 86 ; INPUT: DUZ, but not needed really... here for future expansion 87 ; OUTPUT: At this point "Work" 88 Q "Work" 89 ; 90 ADDLINE1(ADUZ) ; Get Address associated with this instituation; PUBLIC; EXTRINSIC ; CHANGED PARAMETER TO ADUZ TO KEEP FROM CRASHING GPL 1/09 91 ; INPUT: DUZ ByVal 92 ; Output: String. 93 ; 94 ; First, get site number from the institution file. 95 ; 1st piece returned by $$SITE^VASITE, which gets the system institution 96 N INST S INST=$P($$SITE^VASITE(),U) 97 ; 98 ; Second, get mailing address 99 ; There are two APIs to get the address, one for physical and one for 100 ; mailing. We will check if mailing exists first, since that's the 101 ; one we want to use; then check for physical. If neither exists, 102 ; then we return nothing. We check for the existence of an address 103 ; by the length of the returned string. 104 ; NOTE: API doesn't support Address 2, so I won't even include it 105 ; in the template. 106 N ADD 107 S ADD=$$MADD^XUAF4(INST) ; mailing address 108 Q:$L(ADD) $P(ADD,U) 109 S ADD=$$PADD^XUAF4(INST) ; physical address 110 Q:$L(ADD) $P(ADD,U) 111 Q "" 112 ; 113 CITY(ADUZ) ; Get City for Institution. PUBLIC; EXTRINSIC 114 ;GPL CHANGED PARAMETER TO ADUZ TO KEEP $$SITE^VASITE FROM CRASHING 115 ; INPUT: DUZ ByVal 116 ; Output: String. 117 ; See ADD1 for comments 118 N INST S INST=$P($$SITE^VASITE(),U) 119 N ADD 120 S ADD=$$MADD^XUAF4(INST) ; mailing address 121 Q:$L(ADD) $P(ADD,U,2) 122 S ADD=$$PADD^XUAF4(INST) ; physical address 123 Q:$L(ADD) $P(ADD,U,2) 124 Q "" 125 ; 126 STATE(ADUZ) ; Get State for Institution. PUBLIC; EXTRINSIC 127 ; INPUT: DUZ ByVal 128 ; Output: String. 129 ; See ADD1 for comments 130 N INST S INST=$P($$SITE^VASITE(),U) 131 N ADD 132 S ADD=$$MADD^XUAF4(INST) ; mailing address 133 Q:$L(ADD) $P(ADD,U,3) 134 S ADD=$$PADD^XUAF4(INST) ; physical address 135 Q:$L(ADD) $P(ADD,U,3) 136 Q "" 137 ; 138 POSTCODE(ADUZ) ; Get Postal Code for Institution. PUBLIC; EXTRINSIC 139 ; INPUT: DUZ ByVal 140 ; OUTPUT: String. 141 ; See ADD1 for comments 142 N INST S INST=$P($$SITE^VASITE(),U) 143 N ADD 144 S ADD=$$MADD^XUAF4(INST) ; mailing address 145 Q:$L(ADD) $P(ADD,U,4) 146 S ADD=$$PADD^XUAF4(INST) ; physical address 147 Q:$L(ADD) $P(ADD,U,4) 148 Q "" 149 ; 150 TEL(DUZ) ; Get Office Phone number. PUBLIC; EXTRINSIC 151 ; INPUT: DUZ ByVal 152 ; OUTPUT: String. 153 ; Direct global access 154 N TEL S TEL=$G(^VA(200,DUZ,.13)) 155 Q $P(TEL,U,2) 156 ; 157 TELTYPE(DUZ) ; Get Telephone Type. PUBLIC; EXTRINSIC 158 ; INPUT: DUZ ByVal 159 ; OUTPUT: String. 160 Q "Office" 161 ; 162 EMAIL(DUZ) ; Get Provider's Email. PUBLIC; EXTRINSIC 163 ; INPUT: DUZ ByVal 164 ; OUTPUT: String 165 ; Direct global access 166 N EMAIL S EMAIL=$G(^VA(200,DUZ,.15)) 167 Q $P(EMAIL,U) 168 ; -
ccr/trunk/p/C0CVITAL.m
r413 r508 1 C0CVITAL 2 ;; 0.1;CCDCCR;;JUL 16,2008;1 C0CVITAL ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008,2009 George Lilly, University of Minnesota and others. 4 4 ;Licensed under the terms of the GNU General Public License. … … 22 22 Q 23 23 ; 24 EXTRACT(VITXML,DFN,VITOUTXML) 24 EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE 25 25 ; 26 26 ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED … … 191 191 Q 192 192 ; 193 VITDATES(VDT) 193 VITDATES(VDT) ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY 194 194 ; OF DATES IN THE VITALS RESULTS 195 195 N VDTI,VDTJ,VTDCNT -
ccr/trunk/p/C0CXPAT0.m
r391 r508 1 C0CXPAT0 2 ;; 0.2;CCDCCR;nopatch;noreleasedate1 C0CXPAT0 ; CCDCCR/GPL - XPATH TEST CASES ; 6/1/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. -
ccr/trunk/p/C0CXPATH.m
r391 r508 1 C0CXPATH 2 ;; 0.2;CCDCCR;nopatch;noreleasedate1 C0CXPATH ; CCDCCR/GPL - XPATH XML manipulation utilities; 6/1/08 2 ;;1.0;C0C;;May 19, 2009; 3 3 ;Copyright 2008 George Lilly. Licensed under the terms of the GNU 4 4 ;General Public License See attached copy of the License. … … 22 22 Q 23 23 ; 24 OUTPUT(OUTARY,OUTNAME,OUTDIR) 24 OUTPUT(OUTARY,OUTNAME,OUTDIR) ; WRITE AN ARRAY TO A FILE 25 25 ; 26 26 N Y … … 30 30 Q 31 31 ; 32 PUSH(STK,VAL) 32 PUSH(STK,VAL) ; pushs VAL onto STK and updates STK(0) 33 33 ; VAL IS A STRING AND STK IS PASSED BY NAME 34 34 ; … … 38 38 Q 39 39 ; 40 POP(STK,VAL) 40 POP(STK,VAL) ; POPS THE LAST VALUE OFF THE STK AND RETURNS IT IN VAL 41 41 ; VAL AND STK ARE PASSED BY REFERENCE 42 42 ; … … 50 50 Q 51 51 ; 52 PUSHA(ADEST,ASRC) 52 PUSHA(ADEST,ASRC) ; PUSH ASRC ONTO ADEST, BOTH PASSED BY NAME 53 53 ; 54 54 N ZGI … … 57 57 Q 58 58 ; 59 MKMDX(STK,RTN) 59 MKMDX(STK,RTN) ; MAKES A MUMPS INDEX FROM THE ARRAY STK 60 60 ; RTN IS SET TO //FIRST/SECOND/THIRD FOR THREE ARRAY ELEMENTS 61 61 S RTN="" … … 68 68 Q 69 69 ; 70 XNAME(ISTR) 70 XNAME(ISTR) ; FUNCTION TO EXTRACT A NAME FROM AN XML FRAG 71 71 ; </NAME> AND <NAME ID=XNAME> WILL RETURN NAME 72 72 ; ISTR IS PASSED BY VALUE … … 83 83 Q CUR 84 84 ; 85 INDEX(ZXML) 85 INDEX(ZXML) ; parse the XML in ZXML and produce an XPATH index 86 86 ; ex. ZXML(FIRST,SECOND,THIRD,FOURTH)=FIRSTLINE^LASTLINE 87 87 ; WHERE FIRSTLINE AND LASTLINE ARE THE BEGINNING AND ENDING OF THE … … 141 141 Q 142 142 ; 143 QUERY(IARY,XPATH,OARY) 143 QUERY(IARY,XPATH,OARY) ; RETURNS THE XML ARRAY MATCHING THE XPATH EXPRESSION 144 144 ; XPATH IS OF THE FORM "//FIRST/SECOND/THIRD" 145 145 ; IARY AND OARY ARE PASSED BY NAME … … 163 163 Q 164 164 ; 165 XF(IDX,XPATH) 165 XF(IDX,XPATH) ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN XPATH 166 166 ; INDEX WITH TWO PIECES START^FINISH 167 167 ; IDX IS PASSED BY NAME 168 168 Q $P(@IDX@(XPATH),"^",1) 169 169 ; 170 XL(IDX,XPATH) 170 XL(IDX,XPATH) ; EXTRINSIC TO RETURN THE LAST LINE FROM AN XPATH 171 171 ; INDEX WITH TWO PIECES START^FINISH 172 172 ; IDX IS PASSED BY NAME 173 173 Q $P(@IDX@(XPATH),"^",2) 174 174 ; 175 START(ISTR) 175 START(ISTR) ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN INDEX 176 176 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH 177 177 ; COMPANION TO FINISH ; IDX IS PASSED BY NAME 178 178 Q $P(ISTR,";",2) 179 179 ; 180 FINISH(ISTR) 180 FINISH(ISTR) ; EXTRINSIC TO RETURN THE LAST LINE FROM AN INDEX 181 181 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH 182 182 Q $P(ISTR,";",3) 183 183 ; 184 ARRAY(ISTR) 184 ARRAY(ISTR) ; EXTRINSIC TO RETURN THE ARRAY REFERENCE FROM AN INDEX 185 185 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH 186 186 Q $P(ISTR,";",1) 187 187 ; 188 BUILD(BLIST,BDEST) 188 BUILD(BLIST,BDEST) ; A COPY MACHINE THAT TAKE INSTRUCTIONS IN ARRAY BLIST 189 189 ; WHICH HAVE ARRAY;START;FINISH AND COPIES THEM TO DEST 190 190 ; DEST IS CLEARED TO START … … 204 204 Q 205 205 ; 206 QUEUE(BLST,ARRAY,FIRST,LAST) 206 QUEUE(BLST,ARRAY,FIRST,LAST) ; ADD AN ENTRY TO A BLIST 207 207 ; 208 208 I DEBUG W "QUEUEING ",BLST,! … … 210 210 Q 211 211 ; 212 CP(CPSRC,CPDEST) 212 CP(CPSRC,CPDEST) ; COPIES CPSRC TO CPDEST BOTH PASSED BY NAME 213 213 ; KILLS CPDEST FIRST 214 214 N CPINSTR … … 222 222 Q 223 223 ; 224 QOPEN(QOBLIST,QOXML,QOXPATH) 224 QOPEN(QOBLIST,QOXML,QOXPATH) ; ADD ALL BUT THE LAST LINE OF QOXML TO QOBLIST 225 225 ; WARNING NEED TO DO QCLOSE FOR SAME XML BEFORE CALLING BUILD 226 226 ; QOXPATH IS OPTIONAL - WILL OPEN INSIDE THE XPATH POINT … … 242 242 Q 243 243 ; 244 QCLOSE(QCBLIST,QCXML,QCXPATH) 244 QCLOSE(QCBLIST,QCXML,QCXPATH) ; CLOSE XML AFTER A QOPEN 245 245 ; ADDS THE LIST LINE OF QCXML TO QCBLIST 246 246 ; USED TO FINISH INSERTING CHILDERN NODES … … 261 261 Q 262 262 ; 263 INSERT(INSXML,INSNEW,INSXPATH) 263 INSERT(INSXML,INSNEW,INSXPATH) ; INSERT INSNEW INTO INSXML AT THE 264 264 ; INSXPATH XPATH POINT INSXPATH IS OPTIONAL - IF IT IS 265 265 ; OMITTED, INSERTION WILL BE AT THE ROOT … … 287 287 Q 288 288 ; 289 INSINNER(INNXML,INNNEW,INNXPATH) 289 INSINNER(INNXML,INNNEW,INNXPATH) ; INSERT THE INNER XML OF INNNEW 290 290 ; INTO INNXML AT THE INNXPATH XPATH POINT 291 291 ; … … 307 307 Q 308 308 ; 309 INSB4(XDEST,XNEW) 309 INSB4(XDEST,XNEW) ; INSERT XNEW AT THE BEGINNING OF XDEST 310 310 ; BUT XDEST AN XNEW ARE PASSED BY NAME 311 311 N XBLD,XTMP … … 318 318 Q 319 319 ; 320 REPLACE(REXML,RENEW,REXPATH) 320 REPLACE(REXML,RENEW,REXPATH) ; REPLACE THE XML AT THE XPATH POINT 321 321 ; WITH RENEW - NOTE THIS WILL DELETE WHAT WAS THERE BEFORE 322 322 ; REXML AND RENEW ARE PASSED BY NAME XPATH IS A VALUE … … 342 342 Q 343 343 ; 344 MISSING(IXML,OARY) 344 MISSING(IXML,OARY) ; SEARTH THROUGH INXLM AND PUT ANY @@X@@ VARS IN OARY 345 345 ; W "Reporting on the missing",! 346 346 ; W OARY … … 354 354 Q 355 355 ; 356 MAP(IXML,INARY,OXML) 356 MAP(IXML,INARY,OXML) ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY 357 357 ; AND PUT THE RESULTS IN OXML 358 358 I '$D(@IXML@(0)) W "MALFORMED XML PASSED TO MAP",! Q … … 379 379 Q 380 380 ; 381 DOFLD 382 ; 383 Q 384 ; 385 TRIM(THEXML) 381 DOFLD ; PROCESS A FILEMAN FIELD REFERENCED BY A VARIABLE 382 ; 383 Q 384 ; 385 TRIM(THEXML) ; TAKES OUT ALL NULL ELEMENTS 386 386 ; THEXML IS PASSED BY NAME 387 387 N I,J,TMPXML,DEL,FOUND,INTXT … … 421 421 Q FOUND 422 422 ; 423 UNMARK(XSEC) 423 UNMARK(XSEC) ; REMOVE MARKUP FROM FIRST AND LAST LINE OF XML 424 424 ; XSEC IS A SECTION PASSED BY NAME 425 425 N XBLD,XTMP … … 429 429 Q 430 430 ; 431 PARY(GLO) 431 PARY(GLO) ;PRINT AN ARRAY 432 432 N I 433 433 F I=1:1:@GLO@(0) W I_" "_@GLO@(I),! 434 434 Q 435 435 ; 436 H2ARY(IARYRTN,IHASH,IPRE) 436 H2ARY(IARYRTN,IHASH,IPRE) ; CONVERT IHASH TO RETURN ARRAY 437 437 ; IPRE IS OPTIONAL PREFIX FOR THE ELEMENTS. USED FOR MUPTIPLES 1^"VAR"^VALUE 438 438 I '$D(IPRE) S IPRE="" … … 460 460 Q 461 461 ; 462 XVARS(XVRTN,XVIXML) 462 XVARS(XVRTN,XVIXML) ; RETURNS AN ARRAY XVRTN OF ALL UNIQUE VARIABLES 463 463 ; DEFINED IN INPUT XML XVIXML BY @@VAR@@ 464 464 ; XVRTN AND XVIXML ARE PASSED BY NAME … … 471 471 Q 472 472 ; 473 DXVARS(DXIN) 473 DXVARS(DXIN) ;DISPLAY ALL VARIABLES IN A TEMPLATE 474 474 ; IF PARAMETERS ARE NULL, DEFAULTS TO CCR TEMPLATE 475 475 ; … … 487 487 Q 488 488 ; 489 TEST 489 TEST ; Run all the test cases 490 490 D TESTALL^C0CUNIT("C0CXPAT0") 491 491 Q 492 492 ; 493 ZTEST(WHICH) 493 ZTEST(WHICH) ; RUN ONE SET OF TESTS 494 494 N ZTMP 495 495 S DEBUG=1 … … 498 498 Q 499 499 ; 500 TLIST 500 TLIST ; LIST THE TESTS 501 501 N ZTMP 502 502 D ZLOAD^C0CUNIT("ZTMP","C0CXPAT0") -
ccr/trunk/p/LA7QRY1.m
r447 r508 1 1 LA7QRY1 ;DALOI/JMC - Lab HL7 Query Utility ;01/19/99 13:48 2 ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,61**;Sep 27, 1994;Build 26 3 4 5 2 ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,61**;Sep 27, 1994;Build 31 3 ; 4 Q 5 ; 6 6 CHKSC ; Check search NLT/LOINC codes 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 7 ; 8 N J 9 ; 10 S J=0 11 F S J=$O(LA7SC(J)) Q:'J D 12 . N X 13 . S X=LA7SC(J) 14 . I $P(X,"^",2)="NLT",$D(^LAM("E",$P(X,"^"))) D Q 15 . . S ^TMP("LA7-NLT",$J,$P(X,"^"))="" 16 . I $P(X,"^",2)="LN",$D(^LAB(95.3,$P($P(X,"^"),"-"))) D Q 17 . . S ^TMP("LA7-LN",$J,$P($P(X,"^"),"-"))="" 18 . S LA7ERR(6)="Unknown search code "_$P(X,"^")_" passed" 19 . K LA7SC(J) 20 Q 21 ; 22 ; 23 23 SPEC ; Convert HL7 Specimen Codes to File #61, Topography codes 24 25 26 27 28 29 30 31 32 33 24 ; Find all topographies that use this HL7 specimen code 25 N J,K,L 26 ; 27 S J=0 28 F S J=$O(LA7SPEC(J)) Q:'J D 29 . S K=LA7SPEC(J),L=0 30 . F S L=$O(^LAB(61,"HL7",K,L)) Q:'L S ^TMP("LA7-61",$J,L)="" 31 Q 32 ; 33 ; 34 34 BUILDMSG ; Build HL7 message with result of query 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 35 ; 36 N HL,HLECH,HLFS,HLQ,LA,LA763,LA7ECH,LA7FS,LA7MSH,LA7NOMSG,LA7NTESN,LA7NVAF,LA7OBRSN,LA7OBXSN,LA7PIDSN,LA7ROOT,LA7X,X 37 ; 38 I $L($G(LA7HL7))'=5 S LA7HL7="|^\~&" 39 S (HL("FS"),HLFS,LA7FS)=$E(LA7HL7),(HL("ECH"),HLECH,LA7ECH)=$E(LA7HL7,2,5) 40 S (HLQ,HL("Q"))="""""" 41 ; Set flag to not send HL7 message 42 S LA7NOMSG=1 43 ; Create dummy MSH to pass HL7 delimiters 44 S LA7MSH(0)="MSH"_LA7FS_LA7ECH_LA7FS 45 D FILESEG^LA7VHLU(GBL,.LA7MSH) 46 ; 47 F X="AUTO-INST","LRDFN","LRIDT","SUB","HUID","NLT","RUID","SITE" S LA(X)="" 48 ; 49 ; Take search results and put in HL7 message structure 50 S LA7ROOT="^TMP(""LA7-QRY"",$J)",(LA7QUIT,LA7PIDSN)=0 51 ; F S LA7ROOT=$Q(@LA7ROOT) Q:LA7QUIT D ;change per John M 52 F S LA7ROOT=$Q(@LA7ROOT) Q:LA7ROOT="" D Q:LA7QUIT 53 . I $QS(LA7ROOT,1)'="LA7-QRY"!($QS(LA7ROOT,2)'=$J) S LA7QUIT=1 Q 54 . I LA("LRDFN")'=$QS(LA7ROOT,3) D PID S LA7OBRSN=0 55 . I LA("LRIDT")'=$QS(LA7ROOT,4) D ORC,OBR 56 . I LA("SUB")'=$QS(LA7ROOT,5) D ORC,OBR 57 . I LA("NLT")'=$P($QS(LA7ROOT,6),"!") D ORC,OBR 58 . D OBX 59 ; 60 Q 61 ; 62 ; 63 63 PID ; Build PID segment 64 65 66 67 68 69 70 71 72 73 74 75 64 ; 65 N LA7PID 66 ; 67 S (LA("LRDFN"),LRDFN)=$QS(LA7ROOT,3) 68 S LRDPF=$P(^LR(LRDFN,0),"^",2),DFN=$P(^(0),"^",3) 69 D DEM^LRX 70 D PID^LA7VPID(LA("LRDFN"),"",.LA7PID,.LA7PIDSN,.HL) 71 D FILESEG^LA7VHLU(GBL,.LA7PID) 72 S (LA("LRIDT"),LA("SUB"))="" 73 Q 74 ; 75 ; 76 76 ORC ; Build ORC segment 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 77 ; 78 N X 79 ; 80 S LA("LRIDT")=$QS(LA7ROOT,4),LA("SUB")=$QS(LA7ROOT,5) 81 S LA763(0)=$G(^LR(LA("LRDFN"),LA("SUB"),LA("LRIDT"),0)) 82 S X=$G(^LR(LA("LRDFN"),LA("SUB"),LA("LRIDT"),"ORU")) 83 S LA("HUID")=$P(X,"^"),LA("SITE")=$P(X,"^",2),LA("RUID")=$P(X,"^",4) 84 I LA("HUID")="" S LA("HUID")=$P(LA763(0),"^",6) 85 S LA7NVAF=$$NVAF^LA7VHLU2(0),LA7NTESN=0 86 D ORC^LA7VORU 87 S LA("NLT")="" 88 ; 89 Q 90 ; 91 ; 92 92 OBR ; Build OBR segment 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 93 ; 94 N LA764,LA7NLT 95 ; 96 S (LA("NLT"),LA7NLT)=$P($QS(LA7ROOT,6),"!"),(LA764,LA("ORD"))="" 97 I $L(LA7NLT) D 98 . S LA764=+$O(^LAM("E",LA7NLT,0)) 99 . I LA764 S LA("ORD")=$$GET1^DIQ(64,LA764_",",.01) 100 I LA("SUB")="CH" D 101 . D OBR^LA7VORU 102 . D NTE^LA7VORU 103 . S LA7OBXSN=0 104 ; 105 Q 106 ; 107 ; 108 108 OBX ; Build OBX segment 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 109 ; 110 N LA7DATA,LA7VT 111 ; 112 S LA7NTESN=0 113 I LA("SUB")="MI" D MI^LA7VORU1 Q 114 I "CYEMSP"[LA("SUB") D AP^LA7VORU2 Q 115 ; 116 S LA7VT=$QS(LA7ROOT,7) 117 D OBX^LA7VOBX(LA("LRDFN"),LA("SUB"),LA("LRIDT"),LA7VT,.LA7DATA,.LA7OBXSN,LA7FS,LA7ECH) 118 I '$D(LA7DATA) Q 119 D FILESEG^LA7VHLU(GBL,.LA7DATA) 120 ; Send any test interpretation from file #60 121 D INTRP^LA7VORUA 122 ; 123 Q
Note:
See TracChangeset
for help on using the changeset viewer.