Changeset 508 for ccr/trunk


Ignore:
Timestamp:
May 21, 2009, 1:12:11 PM (16 years ago)
Author:
George Lilly
Message:

formatting for Version 1

Location:
ccr/trunk/p
Files:
2 added
32 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/C0CACTOR.m

    r415 r508  
    1 C0CACTOR  ; CCDCCR/GPL - CCR/CCD PROCESSING FOR ACTORS ; 7/3/08
    2  ;;0.4;CCDCCR;nopatch;noreleasedate
     1C0CACTOR        ; CCDCCR/GPL - CCR/CCD PROCESSING FOR ACTORS ; 7/3/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2727 ; 0.4 Patient data rouine refactored; adjustments here--SMH
    2828 ;
    29 EXTRACT(IPXML,ALST,AXML) ; EXTRACT ACTOR FROM ALST INTO PROVIDED XML TEMPLATE
     29EXTRACT(IPXML,ALST,AXML)        ; EXTRACT ACTOR FROM ALST INTO PROVIDED XML TEMPLATE
    3030 ; IPXML is the Input Actor Template into which we  substitute values
    3131 ; This is straight XML. Values to be substituted are in @@VAL@@ format.
     
    8383 Q
    8484 ;
    85 PATIENT(INXML,AIEN,AOID,OUTXML) ; PROCESS A PATIENT ACTOR
     85PATIENT(INXML,AIEN,AOID,OUTXML) ; PROCESS A PATIENT ACTOR
    8686 I DEBUG W "PROCESSING ACTOR PATIENT ",AIEN,!
    8787 N AMAP,ZX
     
    142142 Q
    143143 ;
    144 SYSTEM(INXML,AIEN,AOID,OUTXML) ; PROCESS A SYSTEM ACTOR
     144SYSTEM(INXML,AIEN,AOID,OUTXML)  ; PROCESS A SYSTEM ACTOR
    145145     ;
    146146     ; N AMAP
     
    154154     Q
    155155     ;
    156 NOK(INXML,AIEN,AOID,OUTXML) ; PROCESS A NEXT OF KIN TYPE ACTOR
     156NOK(INXML,AIEN,AOID,OUTXML)     ; PROCESS A NEXT OF KIN TYPE ACTOR
    157157     ;
    158158     ; N AMAP
     
    167167     Q
    168168     ;
    169 ORG(INXML,AIEN,AOID,OUTXML) ; PROCESS AN ORGANIZATION TYPE ACTOR
     169ORG(INXML,AIEN,AOID,OUTXML)     ; PROCESS AN ORGANIZATION TYPE ACTOR
    170170     ;
    171171     ; N AMAP
     
    178178     Q
    179179     ;
    180 PROVIDER(INXML,AIEN,AOID,OUTXML) ; PROCESS A PROVIDER TYPE ACTOR
     180PROVIDER(INXML,AIEN,AOID,OUTXML)        ; PROCESS A PROVIDER TYPE ACTOR
    181181     ;
    182182     ; N AMAP
  • ccr/trunk/p/C0CALERT.m

    r396 r508  
    1 C0CALERT  ; CCDCCR/CKU/GPL - CCR/CCD PROCESSING FOR ALERTS ; 09/11/08
    2  ;;0.1;CCDCCR;;SEP 11,2008;
     1C0CALERT        ; CCDCCR/CKU/GPL - CCR/CCD PROCESSING FOR ALERTS ; 09/11/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota and others.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2222 Q
    2323 ;
    24 EXTRACT(ALTXML,DFN,ALTOUTXML) ; EXTRACT ALERTS INTO PROVIDED XML TEMPLATE
     24EXTRACT(ALTXML,DFN,ALTOUTXML)   ; EXTRACT ALERTS INTO PROVIDED XML TEMPLATE
    2525 ;
    2626 ; ALTXML AND ALTOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
     
    118118 S @ALTTVMAP@(0)=ALTCNT-1 ; RECORD THE NUMBER OF ALERTS
    119119 Q
    120 PRSGLB(INGLB) ; EXTRINSIC TO PARSE GLOBALS AND RETURN THE FILE NUMBER
     120PRSGLB(INGLB)   ; EXTRINSIC TO PARSE GLOBALS AND RETURN THE FILE NUMBER
    121121 ; INGLB IS OF THE FORM: PSNDF(50.6,
    122122 ; RETURN 50.6
  • ccr/trunk/p/C0CBAT.m

    r441 r508  
    1 C0CBAT   ; CCDCCR/GPL - CCR Batch utilities; 4/21/09
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CBAT    ; CCDCCR/GPL - CCR Batch utilities; 4/21/09
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2009 George Lilly.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    2121 Q
    2222 ;
    23 STOP ; STOP A CURRENTLY RUNNING BATCH JOB
     23STOP    ; STOP A CURRENTLY RUNNING BATCH JOB
    2424 I '$D(^TMP("C0CBAT","RUNNING")) Q  ;
    2525 W !,!,"HALTING CCR BATCH",!
     
    3333 Q
    3434 ;
    35 START ; STARTS A TAKSMAN CCR BATCH JOB - FOR USE IN A MENU OPTION
     35START   ; STARTS A TAKSMAN CCR BATCH JOB - FOR USE IN A MENU OPTION
    3636 ;
    3737 I $D(^TMP("C0CBAT","RUNNING")) D  Q  ; ONLY ONE ALLOWED AT A TIME
     
    4848 Q
    4949 ;
    50 EN ; BATCH ENTRY POINT
     50EN      ; BATCH ENTRY POINT
    5151 ; PROCESSES THE SUBSCRIPTION FILE, EXTRACTING CCR VARIABLES FOR EACH
    5252 ; PATIENT WITH AN ACTIVE SUBSCRIPTION, AND IF CHECKSUMS INDICATE A CHANGE,
     
    146146 Q
    147147 ;
    148 BLDHOT(ZHB) ; BUILD HOT LIST AT GLOBAL ZHB, PASSED BY NAME
     148BLDHOT(ZHB)     ; BUILD HOT LIST AT GLOBAL ZHB, PASSED BY NAME
    149149 ; SEARCHS FOR PATIENTS IN THE "AC" INDEX OF THE ORDER FILE
    150150 N ZDFN
     
    156156 Q
    157157 ;
    158 COUNT(ZB) ; EXTRINSIC THAT RETURNS THE NUMBER OF ARRAY ELEMENTS
     158COUNT(ZB)       ; EXTRINSIC THAT RETURNS THE NUMBER OF ARRAY ELEMENTS
    159159 N ZI,ZN
    160160 S ZN=0
     
    164164 Q ZN
    165165 ;
    166 UPDIEVARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
     166UPDIEVARPTR(ZVAR,ZTYP)  ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
    167167 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO
    168168 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO
     
    186186 Q ZVARN
    187187 ;
    188 UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
     188UPDIE   ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
    189189 K ZERR
    190190 D CLEAN^DILF
     
    197197 Q
    198198 ;
    199 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
     199SETFDA(C0CSN,C0CSV)     ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
    200200 ; TO SET TO VALUE C0CSV.
    201201 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE
     
    207207 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV
    208208 Q
    209 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
     209ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
    210210 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
    211211 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    215215 E  S ZR=""
    216216 Q ZR
    217 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
     217ZFIELD(ZFN,ZTAB)        ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
    218218 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
    219219 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    224224 Q ZR
    225225 ;
    226 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
     226ZVALUE(ZFN,ZTAB)        ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
    227227 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
    228228 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
  • ccr/trunk/p/C0CCCD.m

    r416 r508  
    1 C0CCCD   ; CCDCCR/GPL - CCD MAIN PROCESSING; 6/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CCCD    ; CCDCCR/GPL - CCD MAIN PROCESSING; 6/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2121 ; EXPORT A CCR
    2222 ;
    23 EXPORT   ; EXPORT ENTRY POINT FOR CCR
     23EXPORT    ; EXPORT ENTRY POINT FOR CCR
    2424       ; Select a patient.
    2525       S DIC=2,DIC(0)="AEMQ" D ^DIC
     
    2929       Q
    3030       ;
    31 XPAT(DFN,DIR,FN) ; EXPORT ONE PATIENT TO A FILE
     31XPAT(DFN,DIR,FN)        ; EXPORT ONE PATIENT TO A FILE
    3232       ; DIR IS THE DIRECTORY, DEFAULTS IF NULL TO ^TMP("C0CCCR","ODIR")
    3333       ; FN IS FILE NAME, DEFAULTS IF NULL
     
    4949       Q
    5050       ;
    51 CCDRPC(CCRGRTN,DFN,CCRPART,TIME1,TIME2,HDRARY)  ;RPC ENTRY POINT FOR CCR OUTPUT
     51CCDRPC(CCRGRTN,DFN,CCRPART,TIME1,TIME2,HDRARY)  ;RPC ENTRY POINT FOR CCR OUTPUT
    5252    ; CCRGRTN IS RETURN ARRAY PASSED BY NAME
    5353    ; DFN IS PATIENT IEN
     
    146146    Q
    147147    ;
    148 INITSTPS(TAB)  ; INITIALIZE CCR PROCESSING STEPS
     148INITSTPS(TAB)    ; INITIALIZE CCR PROCESSING STEPS
    149149    ; TAB IS PASSED BY NAME
    150150    W "TAB= ",TAB,!
     
    155155    Q
    156156    ;
    157 SHAVE(SHXML) ; REMOVES THE 2-6 AND N-1 AND N-2 LINES FROM A COMPONENT
     157SHAVE(SHXML)    ; REMOVES THE 2-6 AND N-1 AND N-2 LINES FROM A COMPONENT
    158158    ; NEEDED TO EXPOSE THE REPEATING PARTS FOR GENERATION
    159159    N SHTMP,SHBLD ; TEMP ARRAY AND BUILD LIST
     
    168168    Q
    169169    ;
    170 UNSHAVE(ORIGXML,SHXML) ; REPLACES THE 2-6 AND N-1 AND N-2 LINES FROM TEMPLATE
     170UNSHAVE(ORIGXML,SHXML)  ; REPLACES THE 2-6 AND N-1 AND N-2 LINES FROM TEMPLATE
    171171    ; NEEDED TO RESTORM FIXED TOP AND BOTTOM OF THE COMPONENT XML
    172172    N SHTMP,SHBLD ; TEMP ARRAY AND BUILD LIST
     
    181181    Q
    182182    ;
    183 HDRMAP(CXML,DFN,IHDR)   ; MAP HEADER VARIABLES: FROM, TO ECT
     183HDRMAP(CXML,DFN,IHDR)     ; MAP HEADER VARIABLES: FROM, TO ECT
    184184    N VMAP S VMAP=$NA(^TMP("C0CCCR",$J,DFN,"HEADER"))
    185185    ; K @VMAP
     
    200200    Q
    201201    ;
    202 ACTLST(AXML,ACTRTN) ; RETURN THE ACTOR LIST FOR THE XML IN AXML
     202ACTLST(AXML,ACTRTN)     ; RETURN THE ACTOR LIST FOR THE XML IN AXML
    203203    ; AXML AND ACTRTN ARE PASSED BY NAME
    204204    ; EACH ACTOR RECORD HAS 3 PARTS - IE IF OBJECTID=ACTORPATIENT_2
     
    225225    Q
    226226    ;
    227 TEST ; RUN ALL THE TEST CASES
     227TEST    ; RUN ALL THE TEST CASES
    228228  D TESTALL^C0CUNIT("C0CCCR")
    229229  Q
    230230  ;
    231 ZTEST(WHICH)  ; RUN ONE SET OF TESTS
     231ZTEST(WHICH)    ; RUN ONE SET OF TESTS
    232232  N ZTMP
    233233  D ZLOAD^C0CUNIT("ZTMP","C0CCCR")
     
    235235  Q
    236236  ;
    237 TLIST  ; LIST THE TESTS
     237TLIST    ; LIST THE TESTS
    238238  N ZTMP
    239239  D ZLOAD^C0CUNIT("ZTMP","C0CCCR")
  • ccr/trunk/p/C0CCCD1.m

    r391 r508  
    1 C0CCCD1 ; CCDCCR/GPL - CCD TEMPLATE AND ACCESS ROUTINES; 6/7/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CCCD1 ; CCDCCR/GPL - CCD TEMPLATE AND ACCESS ROUTINES; 6/7/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2323          Q
    2424          ;
    25 ZT(ZARY,BAT,LINE) ; private routine to add a line to the ZARY array
     25ZT(ZARY,BAT,LINE)       ; private routine to add a line to the ZARY array
    2626          ; ZARY IS PASSED BY NAME
    2727          ; BAT is a string identifying the section
     
    3838          Q
    3939          ;
    40 ZLOAD(ZARY,ROUTINE) ; load tests into ZARY which is passed by reference
     40ZLOAD(ZARY,ROUTINE)     ; load tests into ZARY which is passed by reference
    4141          ; ZARY IS PASSED BY NAME
    4242          ; ZARY = name of the root, closed array format (e.g., "^TMP($J)")
     
    5858          Q
    5959          ;
    60 LOAD(ARY) ; LOAD A CCR TEMPLATE INTO ARY PASSED BY NAME
     60LOAD(ARY)       ; LOAD A CCR TEMPLATE INTO ARY PASSED BY NAME
    6161          D ZLOAD(ARY,"C0CCCD1")
    6262          ; ZWR @ARY
    6363          Q
    6464          ;
    65 TRMCCD    ; ROUTINE TO BE WRITTEN TO REMOVE CCR MARKUP FROM CCD
    66           Q
    67 MARKUP ;<MARKUP>
     65TRMCCD     ; ROUTINE TO BE WRITTEN TO REMOVE CCR MARKUP FROM CCD
     66          Q
     67MARKUP  ;<MARKUP>
    6868 ;;<Body>
    6969 ;;<Problems>
  • ccr/trunk/p/C0CCCR.m

    r441 r508  
    1 C0CCCR   ; CCDCCR/GPL - CCR MAIN PROCESSING; 6/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CCCR    ; CCDCCR/GPL - CCR MAIN PROCESSING; 6/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2121 ; EXPORT A CCR
    2222 ;
    23 EXPORT   ; EXPORT ENTRY POINT FOR CCR
     23EXPORT    ; EXPORT ENTRY POINT FOR CCR
    2424 ; Select a patient.
    2525 S DIC=2,DIC(0)="AEMQ" D ^DIC
     
    2929 Q
    3030 ;
    31 XPAT(DFN,XPARMS,DIR,FN) ; EXPORT ONE PATIENT TO A FILE
     31XPAT(DFN,XPARMS,DIR,FN) ; EXPORT ONE PATIENT TO A FILE
    3232 ; DIR IS THE DIRECTORY, DEFAULTS IF NULL TO ^TMP("C0CCCR","ODIR")
    3333 ; FN IS FILE NAME, DEFAULTS IF NULL
     
    4141 S OARY=$NA(^TMP("C0CCCR",$J,DFN,"CCR",1))
    4242 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"
    4444 S ODIRGLB=$NA(^TMP("C0CCCR","ODIR"))
    4545 S ^TMP("C0CCCR","FNAME",DFN)=ONAM ; FILE NAME FOR BATCH USE
     
    5757 Q
    5858 ;
    59 DCCR(DFN) ; DISPLAY A CCR THAT HAS JUST BEEN EXTRACTED
     59DCCR(DFN)       ; DISPLAY A CCR THAT HAS JUST BEEN EXTRACTED
    6060 ;
    6161 N G1
     
    6666 Q
    6767 ;
    68 CCRRPC(CCRGRTN,DFN,CCRPARMS,CCRPART)  ;RPC ENTRY POINT FOR CCR OUTPUT
     68CCRRPC(CCRGRTN,DFN,CCRPARMS,CCRPART)    ;RPC ENTRY POINT FOR CCR OUTPUT
    6969 ; CCRGRTN IS RETURN ARRAY PASSED BY NAME
    7070 ; DFN IS PATIENT IEN
     
    131131 Q
    132132 ;
    133 INITSTPS(TAB)  ; INITIALIZE CCR PROCESSING STEPS
     133INITSTPS(TAB)    ; INITIALIZE CCR PROCESSING STEPS
    134134 ; TAB IS PASSED BY NAME
    135135 I DEBUG W "TAB= ",TAB,!
     
    143143 Q
    144144 ;
    145 HDRMAP(CXML,DFN) ; MAP HEADER VARIABLES: FROM, TO ECT
     145HDRMAP(CXML,DFN)        ; MAP HEADER VARIABLES: FROM, TO ECT
    146146 N VMAP S VMAP=$NA(^TMP("C0CCCR",$J,DFN,"HEADER"))
    147147 ; K @VMAP
     
    167167 Q
    168168 ;
    169 ACTLST(AXML,ACTRTN) ; RETURN THE ACTOR LIST FOR THE XML IN AXML
     169ACTLST(AXML,ACTRTN)     ; RETURN THE ACTOR LIST FOR THE XML IN AXML
    170170 ; AXML AND ACTRTN ARE PASSED BY NAME
    171171 ; EACH ACTOR RECORD HAS 3 PARTS - IE IF OBJECTID=ACTORPATIENT_2
     
    192192 Q
    193193 ;
    194 TEST ; RUN ALL THE TEST CASES
     194TEST    ; RUN ALL THE TEST CASES
    195195 D TESTALL^C0CUNIT("C0CCCR")
    196196 Q
    197197 ;
    198 ZTEST(WHICH)  ; RUN ONE SET OF TESTS
     198ZTEST(WHICH)    ; RUN ONE SET OF TESTS
    199199 N ZTMP
    200200 D ZLOAD^C0CUNIT("ZTMP","C0CCCR")
     
    202202 Q
    203203 ;
    204 TLIST  ; LIST THE TESTS
     204TLIST    ; LIST THE TESTS
    205205 N ZTMP
    206206 D ZLOAD^C0CUNIT("ZTMP","C0CCCR")
     
    238238 ;;>>>D CCRRPC^C0CCCR(.C0C,"2","ALERTS","")
    239239 ;;>>?@C0C@(@C0C@(0))["</Alerts>"
    240 
     240 
  • ccr/trunk/p/C0CCCR0.m

    r392 r508  
    1 C0CCCR0 ; CCDCCR/GPL - CCR TEMPLATE AND ACCESS ROUTINES; 5/31/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CCCR0 ; CCDCCR/GPL - CCR TEMPLATE AND ACCESS ROUTINES; 5/31/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2323 Q
    2424 ;
    25 ZT(ZARY,BAT,LINE)       ; private routine to add a line to the ZARY array
     25ZT(ZARY,BAT,LINE)             ; private routine to add a line to the ZARY array
    2626 ; ZARY IS PASSED BY NAME
    2727 ; BAT is a string identifying the section
     
    3838 Q
    3939 ;
    40 ZLOAD(ZARY,ROUTINE)      ; load tests into ZARY which is passed by reference
     40ZLOAD(ZARY,ROUTINE)          ; load tests into ZARY which is passed by reference
    4141 ; ZARY IS PASSED BY NAME
    4242 ; ZARY = name of the root, closed array format (e.g., "^TMP($J)")
     
    5858 Q
    5959 ;
    60 LOAD(ARY)       ; LOAD A CCR TEMPLATE INTO ARY PASSED BY NAME
     60LOAD(ARY)             ; LOAD A CCR TEMPLATE INTO ARY PASSED BY NAME
    6161 D ZLOAD(ARY,"C0CCCR0")
    6262 ; ZWR @ARY
  • ccr/trunk/p/C0CDPT.m

    r415 r508  
    1 C0CDPT ;WV/CCRCCD/SMH - Routines to Extract Patient Data for CCDCCR; 6/15/08
    2  ;;0.2;CCRCCD;;Jun 15, 2008;
     1C0CDPT  ;WV/CCRCCD/SMH - Routines to Extract Patient Data for CCDCCR; 6/15/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;
    44 ; Copyright 2008 WorldVistA.  Licensed under the terms of the GNU
     
    8787 ; You can obtain field numbers using the data dictionary
    8888 ;
    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
     89FAMILY(DFN)     ; Family Name
     90 N NAME S NAME=$$GET1^DIQ(2,DFN,.01)
     91 D NAMECOMP^XLFNAME(.NAME)
     92 Q NAME("FAMILY")
     93GIVEN(DFN)      ; Given Name
     94 N NAME S NAME=$$GET1^DIQ(2,DFN,.01)
     95 D NAMECOMP^XLFNAME(.NAME)
     96 Q NAME("GIVEN")
     97MIDDLE(DFN)     ; Middle Name
     98 N NAME S NAME=$$GET1^DIQ(2,DFN,.01)
     99 D NAMECOMP^XLFNAME(.NAME)
     100 Q NAME("MIDDLE")
     101SUFFIX(DFN)     ; Suffi Name
     102 N NAME S NAME=$$GET1^DIQ(2,DFN,.01)
     103 D NAMECOMP^XLFNAME(.NAME)
     104 Q NAME("SUFFIX")
     105DISPNAME(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")
     109DOB(DFN)        ; Date of Birth
    110110 N DOB S DOB=$$GET1^DIQ(2,DFN,.03,"I")
    111111 ; Date in FM Date Format. Convert to UTC/ISO 8601.
    112112 Q $$FMDTOUTC^C0CUTIL(DOB,"D")
    113 GENDER(DFN) ; Gender/Sex
     113GENDER(DFN)     ; Gender/Sex
    114114 Q $$GET1^DIQ(2,DFN,.02) ;
    115 SSN(DFN) ; SSN
     115SSN(DFN)        ; SSN
    116116 Q $$GET1^DIQ(2,DFN,.09)
    117 ADDRTYPE(DFN) ; Address Type
     117ADDRTYPE(DFN)   ; Address Type
    118118 ; Vista only stores a home address for the patient.
    119119 Q "Home"
    120 ADDR1(DFN) ; Get Home Address line 1
     120ADDR1(DFN)      ; Get Home Address line 1
    121121 Q $$GET1^DIQ(2,DFN,.111)
    122 ADDR2(DFN) ; Get Home Address line 2
     122ADDR2(DFN)      ; Get Home Address line 2
    123123 ; Vista has Lines 2,3; CCR has only line 1,2; so compromise
    124124 N ADDLN2,ADDLN3
     
    126126 Q:ADDLN3="" ADDLN2
    127127 Q ADDLN2_", "_ADDLN3
    128 CITY(DFN) ; Get City for Home Address
     128CITY(DFN)       ; Get City for Home Address
    129129 Q $$GET1^DIQ(2,DFN,.114)
    130 STATE(DFN) ; Get State for Home Address
     130STATE(DFN)      ; Get State for Home Address
    131131 Q $$GET1^DIQ(2,DFN,.115)
    132 ZIP(DFN) ; Get Zip code for Home Address
     132ZIP(DFN)        ; Get Zip code for Home Address
    133133 Q $$GET1^DIQ(2,DFN,.116)
    134 COUNTY(DFN) ; Get County for our Address
     134COUNTY(DFN)     ; Get County for our Address
    135135 Q $$GET1^DIQ(2,DFN,.117)
    136 COUNTRY(DFN) ; Get Country for our Address
     136COUNTRY(DFN)    ; Get Country for our Address
    137137 ; Unfortunately, it's not stored anywhere in Vista, so the inevitable...
    138138 Q "USA"
    139 RESTEL(DFN) ; Residential Telephone
     139RESTEL(DFN)     ; Residential Telephone
    140140 Q $$GET1^DIQ(2,DFN,.131)
    141 WORKTEL(DFN) ; Work Telephone
     141WORKTEL(DFN)    ; Work Telephone
    142142 Q $$GET1^DIQ(2,DFN,.132)
    143 EMAIL(DFN) ; Email Adddress
     143EMAIL(DFN)      ; Email Adddress
    144144 Q $$GET1^DIQ(2,DFN,.133)
    145 CELLTEL(DFN) ; Cell Phone
     145CELLTEL(DFN)    ; Cell Phone
    146146 Q $$GET1^DIQ(2,DFN,.134)
    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
     147NOK1FAM(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")
     151NOK1GIV(DFN)    ; NOK1 Given Name
     152 N NAME S NAME=$$GET1^DIQ(2,DFN,.211)
     153 D NAMECOMP^XLFNAME(.NAME)
     154 Q NAME("GIVEN")
     155NOK1MID(DFN)    ; NOK1 Middle Name
     156 N NAME S NAME=$$GET1^DIQ(2,DFN,.211)
     157 D NAMECOMP^XLFNAME(.NAME)
     158 Q NAME("MIDDLE")
     159NOK1SUF(DFN)    ; NOK1 Suffi Name
     160 N NAME S NAME=$$GET1^DIQ(2,DFN,.211)
     161 D NAMECOMP^XLFNAME(.NAME)
     162 Q NAME("SUFFIX")
     163NOK1DISP(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")
     167NOK1REL(DFN)    ; NOK1 Relationship to the patient
    168168 Q $$GET1^DIQ(2,DFN,.212)
    169 NOK1ADD1(DFN) ; NOK1 Address 1
     169NOK1ADD1(DFN)   ; NOK1 Address 1
    170170 Q $$GET1^DIQ(2,DFN,.213)
    171 NOK1ADD2(DFN) ; NOK1 Address 2
     171NOK1ADD2(DFN)   ; NOK1 Address 2
    172172 N ADDLN2,ADDLN3
    173173 S ADDLN2=$$GET1^DIQ(2,DFN,.214),ADDLN3=$$GET1^DIQ(2,DFN,.215)
    174174 Q:ADDLN3="" ADDLN2
    175175 Q ADDLN2_", "_ADDLN3
    176 NOK1CITY(DFN) ; NOK1 City
     176NOK1CITY(DFN)   ; NOK1 City
    177177 Q $$GET1^DIQ(2,DFN,.216)
    178 NOK1STAT(DFN) ; NOK1 State
     178NOK1STAT(DFN)   ; NOK1 State
    179179 Q $$GET1^DIQ(2,DFN,.217)
    180 NOK1ZIP(DFN) ; NOK1 Zip Code
     180NOK1ZIP(DFN)    ; NOK1 Zip Code
    181181 Q $$GET1^DIQ(2,DFN,.218)
    182 NOK1HTEL(DFN) ; NOK1 Home Telephone
     182NOK1HTEL(DFN)   ; NOK1 Home Telephone
    183183 Q $$GET1^DIQ(2,DFN,.219)
    184 NOK1WTEL(DFN) ; NOK1 Work Telephone
     184NOK1WTEL(DFN)   ; NOK1 Work Telephone
    185185 Q $$GET1^DIQ(2,DFN,.21011)
    186 NOK1SAME(DFN) ; Is NOK1's Address the same the patient?
     186NOK1SAME(DFN)   ; Is NOK1's Address the same the patient?
    187187 Q $$GET1^DIQ(2,DFN,.2125)
    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
     188NOK2FAM(DFN)    ; NOK2 Family Name
     189 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191)
     190 D NAMECOMP^XLFNAME(.NAME)
     191 Q NAME("FAMILY")
     192NOK2GIV(DFN)    ; NOK2 Given Name
     193 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191)
     194 D NAMECOMP^XLFNAME(.NAME)
     195 Q NAME("GIVEN")
     196NOK2MID(DFN)    ; NOK2 Middle Name
     197 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191)
     198 D NAMECOMP^XLFNAME(.NAME)
     199 Q NAME("MIDDLE")
     200NOK2SUF(DFN)    ; NOK2 Suffi Name
     201 N NAME S NAME=$$GET1^DIQ(2,DFN,.2191)
     202 D NAMECOMP^XLFNAME(.NAME)
     203 Q NAME("SUFFIX")
     204NOK2DISP(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")
     208NOK2REL(DFN)    ; NOK2 Relationship to the patient
    209209 Q $$GET1^DIQ(2,DFN,.2192)
    210 NOK2ADD1(DFN) ; NOK2 Address 1
     210NOK2ADD1(DFN)   ; NOK2 Address 1
    211211 Q $$GET1^DIQ(2,DFN,.2193)
    212 NOK2ADD2(DFN) ; NOK2 Address 2
     212NOK2ADD2(DFN)   ; NOK2 Address 2
    213213 N ADDLN2,ADDLN3
    214214 S ADDLN2=$$GET1^DIQ(2,DFN,.2194),ADDLN3=$$GET1^DIQ(2,DFN,.2195)
    215215 Q:ADDLN3="" ADDLN2
    216216 Q ADDLN2_", "_ADDLN3
    217 NOK2CITY(DFN) ; NOK2 City
     217NOK2CITY(DFN)   ; NOK2 City
    218218 Q $$GET1^DIQ(2,DFN,.2196)
    219 NOK2STAT(DFN) ; NOK2 State
     219NOK2STAT(DFN)   ; NOK2 State
    220220 Q $$GET1^DIQ(2,DFN,.2197)
    221 NOK2ZIP(DFN) ; NOK2 Zip Code
     221NOK2ZIP(DFN)    ; NOK2 Zip Code
    222222 Q $$GET1^DIQ(2,DFN,.2198)
    223 NOK2HTEL(DFN) ; NOK2 Home Telephone
     223NOK2HTEL(DFN)   ; NOK2 Home Telephone
    224224 Q $$GET1^DIQ(2,DFN,.2199)
    225 NOK2WTEL(DFN) ; NOK2 Work Telephone
     225NOK2WTEL(DFN)   ; NOK2 Work Telephone
    226226 Q $$GET1^DIQ(2,DFN,.211011)
    227 NOK2SAME(DFN) ; Is NOK2's Address the same the patient?
     227NOK2SAME(DFN)   ; Is NOK2's Address the same the patient?
    228228 Q $$GET1^DIQ(2,DFN,.21925)
    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
     229EMERFAM(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")
     233EMERGIV(DFN)    ; EMER Given Name
     234 N NAME S NAME=$$GET1^DIQ(2,DFN,.331)
     235 D NAMECOMP^XLFNAME(.NAME)
     236 Q NAME("GIVEN")
     237EMERMID(DFN)    ; EMER Middle Name
     238 N NAME S NAME=$$GET1^DIQ(2,DFN,.331)
     239 D NAMECOMP^XLFNAME(.NAME)
     240 Q NAME("MIDDLE")
     241EMERSUF(DFN)    ; EMER Suffi Name
     242 N NAME S NAME=$$GET1^DIQ(2,DFN,.331)
     243 D NAMECOMP^XLFNAME(.NAME)
     244 Q NAME("SUFFIX")
     245EMERDISP(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")
     249EMERREL(DFN)    ; EMER Relationship to the patient
    250250 Q $$GET1^DIQ(2,DFN,.331)
    251 EMERADD1(DFN) ; EMER Address 1
     251EMERADD1(DFN)   ; EMER Address 1
    252252 Q $$GET1^DIQ(2,DFN,.333)
    253 EMERADD2(DFN) ; EMER Address 2
     253EMERADD2(DFN)   ; EMER Address 2
    254254 N ADDLN2,ADDLN3
    255255 S ADDLN2=$$GET1^DIQ(2,DFN,.334),ADDLN3=$$GET1^DIQ(2,DFN,.335)
    256256 Q:ADDLN3="" ADDLN2
    257257 Q ADDLN2_", "_ADDLN3
    258 EMERCITY(DFN) ; EMER City
     258EMERCITY(DFN)   ; EMER City
    259259 Q $$GET1^DIQ(2,DFN,.336)
    260 EMERSTAT(DFN) ; EMER State
     260EMERSTAT(DFN)   ; EMER State
    261261 Q $$GET1^DIQ(2,DFN,.337)
    262 EMERZIP(DFN) ; EMER Zip Code
     262EMERZIP(DFN)    ; EMER Zip Code
    263263 Q $$GET1^DIQ(2,DFN,.338)
    264 EMERHTEL(DFN) ; EMER Home Telephone
     264EMERHTEL(DFN)   ; EMER Home Telephone
    265265 Q $$GET1^DIQ(2,DFN,.339)
    266 EMERWTEL(DFN) ; EMER Work Telephone
     266EMERWTEL(DFN)   ; EMER Work Telephone
    267267 Q $$GET1^DIQ(2,DFN,.33011)
    268 EMERSAME(DFN) ; Is EMER's Address the same the NOK?
     268EMERSAME(DFN)   ; Is EMER's Address the same the NOK?
    269269 Q $$GET1^DIQ(2,DFN,.3305)
  • ccr/trunk/p/C0CFM1.m

    r404 r508  
    1 C0CFM1   ; CCDCCR/GPL - CCR FILEMAN utilities; 12/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CFM1    ; CCDCCR/GPL - CCR FILEMAN utilities; 12/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2009 George Lilly.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    2222 Q
    2323 ;
    24 PUTRIM(DFN,ZWHICH) ;DFN IS PATIENT , WHICH IS ELEMENT TYPE
     24PUTRIM(DFN,ZWHICH)      ;DFN IS PATIENT , WHICH IS ELEMENT TYPE
    2525 ;
    2626 S C0CGLB=$NA(^TMP("GPLRIM","VARS",DFN))
     
    3737 Q
    3838 ;
    39 PUTRIM1(DFN,ZZTYP,ZVARS) ; PUT ONE SECTION OF VARIABLES INTO CCR ELEMENTS
     39PUTRIM1(DFN,ZZTYP,ZVARS)        ; PUT ONE SECTION OF VARIABLES INTO CCR ELEMENTS
    4040 ; ZVARS IS PASSED BY NAME AN HAS THE FORM @ZVARS@(1,"VAR1")="VAL1"
    4141 S C0CX=0
     
    4646 Q
    4747 ;
    48 PUTELS(DFN,ZTYPE,ZOCC,ZVALS) ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE
     48PUTELS(DFN,ZTYPE,ZOCC,ZVALS)    ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE
    4949 ; ^C0C(171.201,   DFN IS THE PATIENT IEN PASSED BY VALUE
    5050 ; ZTYPE IS THE NODE TYPE IE RESULTS,PROBLEMS PASSED BY VALUE
     
    9393 Q
    9494 ;
    95 VARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
     95VARPTR(ZVAR,ZTYP)       ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
    9696 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO
    9797 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO
     
    115115 Q ZVARN
    116116 ;
    117 BLDTYPS ; ROUTINE TO POPULATE THE CCR NODE TYPES FILE (^C0CDIC(170.101,)
     117BLDTYPS ; ROUTINE TO POPULATE THE CCR NODE TYPES FILE (^C0CDIC(170.101,)
    118118 ; THE CCR DICTIONARY (^C0CDIC(170, ) HAS MOST OF WHAT'S NEEDED
    119119 ;
     
    123123 Q
    124124 ;
    125 FIXSEC ;FIX THE SECTION FIELD OF THE CCR DICTIONARY.. IT HAS BEEN REDEFINED
     125FIXSEC  ;FIX THE SECTION FIELD OF THE CCR DICTIONARY.. IT HAS BEEN REDEFINED
    126126 ; AS A POINTER TO CCR NODE TYPE INSTEAD OF BEING A SET
    127127 ; THE SET VALUES ARE PRESERVED IN ^KBAI("SECTION") TO FACILITATE THIS
     
    140140 Q
    141141 ;
    142 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
     142SETFDA(C0CSN,C0CSV)     ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
    143143 ; TO SET TO VALUE C0CSV.
    144144 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE
     
    150150 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV
    151151 Q
    152 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
     152ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
    153153 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
    154154 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    158158 E  S ZR=""
    159159 Q ZR
    160 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
     160ZFIELD(ZFN,ZTAB)        ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
    161161 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
    162162 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    167167 Q ZR
    168168 ;
    169 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
     169ZVALUE(ZFN,ZTAB)        ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
    170170 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
    171171 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
  • ccr/trunk/p/C0CFM2.m

    r433 r508  
    1 C0CFM2   ; CCDCCR/GPL - CCR FILEMAN utilities; 12/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CFM2    ; CCDCCR/GPL - CCR FILEMAN utilities; 12/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2009 George Lilly.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    2828 Q
    2929 ;
    30 RIMTBL(ZWHICH) ; PUT ALL PATIENT IN RIMTBL ZWHICH INTO THE CCR ELEMENTS FILE
     30RIMTBL(ZWHICH)  ; PUT ALL PATIENT IN RIMTBL ZWHICH INTO THE CCR ELEMENTS FILE
    3131 ;
    3232 I '$D(RIMBASE) D ASETUP^C0CRIMA ; FOR COMMAND LINE CALLS
     
    3939 Q
    4040 ;
    41 PUTRIM(DFN,ZWHICH) ;DFN IS PATIENT , WHICH IS ELEMENT TYPE
     41PUTRIM(DFN,ZWHICH)      ;DFN IS PATIENT , WHICH IS ELEMENT TYPE
    4242 ;
    4343 S C0CGLB=$NA(^TMP("C0CRIM","VARS",DFN))
     
    5454 Q
    5555 ;
    56 PUTRIM1(DFN,ZZTYP,ZVARS) ; PUT ONE SECTION OF VARIABLES INTO CCR ELEMENTS
     56PUTRIM1(DFN,ZZTYP,ZVARS)        ; PUT ONE SECTION OF VARIABLES INTO CCR ELEMENTS
    5757 ; ZVARS IS PASSED BY NAME AN HAS THE FORM @ZVARS@(1,"VAR1")="VAL1"
    5858 S C0CX=0
     
    7878 Q
    7979 ;
    80 PUTELS(DFN,ZTYPE,ZOCC,ZVALS) ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE
     80PUTELS(DFN,ZTYPE,ZOCC,ZVALS)    ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE
    8181 ; 171.101, ^C0CE  DFN IS THE PATIENT IEN PASSED BY VALUE
    8282 ; ZTYPE IS THE NODE TYPE IE RESULTS,PROBLEMS PASSED BY VALUE
     
    145145 Q
    146146 ;
    147 UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
     147UPDIE   ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
    148148 K ZERR
    149149 D CLEAN^DILF
     
    156156 Q
    157157 ;
    158 CHECK ; CHECKSUM EXPERIMENTS
     158CHECK   ; CHECKSUM EXPERIMENTS
    159159 ;
    160160 ;B
     
    165165 Q
    166166 ;
    167 CHKELS(DFN) ; CHECKSUM ALL ELEMENTS FOR  A PATIENT
     167CHKELS(DFN)     ; CHECKSUM ALL ELEMENTS FOR  A PATIENT
    168168 ;
    169169 S ZGLB=$NA(^TMP("C0CCHK"))
     
    186186 Q
    187187 ;
    188 DOIT(DFN) ; EXPERIMENT FOR TIMING CALLS USING mumps -dir DOIT^C0CFM2(DFN)
     188DOIT(DFN)       ; EXPERIMENT FOR TIMING CALLS USING mumps -dir DOIT^C0CFM2(DFN)
    189189 D SETXUP
    190190 D CHKELS(DFN)
    191191 Q
    192192 ;
    193 SETXUP ; SET UP ENVIRONMENT
     193SETXUP  ; SET UP ENVIRONMENT
    194194 S DISYS=19
    195195 S DT=3090325
     
    224224 Q
    225225 ;
    226 PUTELSOLD(DFN,ZTYPE,ZOCC,ZVALS) ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE
     226PUTELSOLD(DFN,ZTYPE,ZOCC,ZVALS) ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE
    227227 ; 171.101, ^C0CE  DFN IS THE PATIENT IEN PASSED BY VALUE
    228228 ; ZTYPE IS THE NODE TYPE IE RESULTS,PROBLEMS PASSED BY VALUE
     
    278278 Q
    279279 ;
    280 VARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
     280VARPTR(ZVAR,ZTYP)       ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
    281281 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO
    282282 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO
     
    300300 Q ZVARN
    301301 ;
    302 BLDTYPS ; ROUTINE TO POPULATE THE CCR NODE TYPES FILE (^C0CDIC(170.101,)
     302BLDTYPS ; ROUTINE TO POPULATE THE CCR NODE TYPES FILE (^C0CDIC(170.101,)
    303303 ; THE CCR DICTIONARY (^C0CDIC(170, ) HAS MOST OF WHAT'S NEEDED
    304304 ;
     
    308308 Q
    309309 ;
    310 FIXSEC ;FIX THE SECTION FIELD OF THE CCR DICTIONARY.. IT HAS BEEN REDEFINED
     310FIXSEC  ;FIX THE SECTION FIELD OF THE CCR DICTIONARY.. IT HAS BEEN REDEFINED
    311311 ; AS A POINTER TO CCR NODE TYPE INSTEAD OF BEING A SET
    312312 ; THE SET VALUES ARE PRESERVED IN ^KBAI("SECTION") TO FACILITATE THIS
     
    325325 Q
    326326 ;
    327 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
     327SETFDA(C0CSN,C0CSV)     ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
    328328 ; TO SET TO VALUE C0CSV.
    329329 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE
     
    335335 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV
    336336 Q
    337 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
     337ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
    338338 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
    339339 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    343343 E  S ZR=""
    344344 Q ZR
    345 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
     345ZFIELD(ZFN,ZTAB)        ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
    346346 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
    347347 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    352352 Q ZR
    353353 ;
    354 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
     354ZVALUE(ZFN,ZTAB)        ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
    355355 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
    356356 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
  • ccr/trunk/p/C0CIMMU.m

    r396 r508  
    1 C0CIMMU ; CCDCCR/GPL - CCR/CCD PROCESSING FOR IMMUNIZATIONS ; 2/2/09
    2  ;;0.1;CCDCCR;nopatch;noreleasedate;Build 7
     1C0CIMMU ; CCDCCR/GPL - CCR/CCD PROCESSING FOR IMMUNIZATIONS ; 2/2/09
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2222 ; PROCESS THE IMMUNIZATIONS SECTION OF THE CCR
    2323 ;
    24 MAP(IPXML,DFN,OUTXML) ; MAP IMMUNIZATIONS
     24MAP(IPXML,DFN,OUTXML)   ; MAP IMMUNIZATIONS
    2525 ;
    2626 N C0CZV,C0CZVI ; TO STORE MAPPED VARIABLES
     
    4747 Q
    4848 ;
    49 EXTRACT(IPXML,DFN,OUTXML) ; EXTRACT IMMUNIZATIONS INTO VARIABLES
     49EXTRACT(IPXML,DFN,OUTXML)       ; EXTRACT IMMUNIZATIONS INTO VARIABLES
    5050 ;
    5151 ; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
  • ccr/trunk/p/C0CLA7Q.m

    r505 r508  
    11C0CLA7Q ;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 ;
    89LAB(C0CPTID,C0CSDT,C0CEDT,C0CSC,C0CSPEC,C0CERR,C0CDEST,C0CHL7)  ; Entry point for Lab Result Query
    9         ;
    10         ;
    11         K ^TMP("C0C-VLAB",$J)
    12         ;
    13         ; Check and retrieve lab results from LAB DATA file (#63)
    14         S C0CDEST=$$GCPR^LA7QRY($G(C0CPTID),$G(C0CSDT),$G(C0CEDT),.C0CSC,.C0CSPEC,.C0CERR,$G(C0CDEST),$G(C0CHL7))
    15         ;
    16         ; If V LAB file present then check for lab results that are only in this file
    17         ; If results found in V Lab file then build results and add to above results.
    18         I $D(^AUPNVLAB) D
    19         . D VCHECK
    20         . I $D(^TMP("C0C-VLAB",$J,3)) D VBUILD
    21         ;
    22         ;K ^TMP("C0C-VLAB",$J)
    23         ;
    24         Q C0CDEST
    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 ;
    2728VCHECK  ; If V LAB file present then check for lab results that are only in this file.
    28         ;
    29         N C0CDA,C0CEND,C0CROOT,C0CVLAB,LA7PTID,LA7SC,LA7SCRC,LA7SPEC
    30         ;
    31         S LA7PTID=C0CPTID
    32         D PATID^LA7QRY2
    33         I $D(LA7ERR) Q
    34         ;
    35         ; Resolve search codes to lab datanames
    36         S LA7SC=$G(C0CSC)
    37         I $T(SCLIST^LA7QRY2)'="" D
    38         . N TMP
    39         . S LA7SCSRC=$G(C0CSC)
    40         . S TMP=$$SCLIST^LA7QRY2(LA7SCSRC)
    41         . S LA7SC=TMP
    42         ;
    43         I LA7SC'="*" D CHKSC^LA7QRY1
    44         ;
    45         ; Convert specimen codes to file #61 Topography entries
    46         S LA7SPEC=$G(C0CSPEC)
    47         I LA7SPEC'="*"  D SPEC^LA7QRY1
    48         ;
    49         S C0CROOT="^AUPNVLAB(""ALR4"",DFN,C0CSDT)",C0CEND=0
    50         ;
    51         F  S C0CROOT=$Q(@C0CROOT) Q:C0CROOT=""  D  Q:C0CEND
    52         . I $QS(C0CROOT,1)'="ALR4"!($QS(C0CROOT,2)'=DFN) S C0CEND=1 Q  ; Left x-ref or patient
    53         . I $QS(C0CROOT,3)>C0CEDT S C0CEND=1 Q  ; Exceeded end date/time
    54         . S C0CDA=$QS(C0CROOT,4)
    55         . I $D(^TMP("C0C-VLAB",$J,1,C0CDA)) Q  ; Already checked during scan of file #63
    56         . I $P($G(^AUPNVLAB(C0CDA,11)),"^",8)=1 Q  ; Source is LAB DATA file - skip
    57         . D VCHK1
    58         ;
    59         ;
    60         Q
    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 ;
    6364VBUILD  ; Build results found only in V LAB file into HL7 structure.
    64         ;
    65         ;
    66         Q
    67         ;
    68         ;
     65 ;
     66 ;
     67 Q
     68 ;
     69 ;
    6970LNCHK   ; Check for corresponding entry in V LAB file and related LOINC code for a result in file #63.
    70         ; Call from LA7QRY2
    71         ;
    72         N DFN,C0C60,C0C63,C0CACC,C0CDA,C0CDT,C0CLN,C0CPDA,C0CPTEST,C0CSPEC,C0CTEST,X
    73         ;
    74         S DFN=$P(^LR(LRDFN,0),"^",3)
    75         S C0C63(0)=^LR(LRDFN,LRSS,LRIDT,0)
    76         S C0CDT=$P(C0C63(0),"^"),C0CACC=$P(C0C63(0),"^",6),C0CSPEC=$P(C0C63(0),"^",5)
    77         S (C0CTEST,C0CTEST(64),C0CPTEST,C0CPTEST(64),C0CLN)=""
    78         ;
    79         ; ^AUPNVLAB("ALR1",5380,"EKT 0307 48",173,3080307.211055,5427197)=""
    80         ;
    81         S C0C60=""
    82         F  S C0C60=$O(^LAB(60,"C",LRSS_";"_LRSB_";1",C0C60)) Q:'C0C60  D  Q:C0CLN'=""
    83         . D FINDDT
    84         . I C0CDA<1 Q
    85         . I $P($G(^AUPNVLAB(C0CDA,11)),"^",8)'=1 Q  ; Source is not LAB DATA file - skip
    86         . S C0CLN=$P($G(^AUPNVLAB(C0CDA,11)),"^",13)
    87         . S C0CPDA=$P($G(^AUPNVLAB(C0CDA,12)),"^",8)
    88         . I C0CPDA="" S C0CPDA=C0CDA
    89         . S C0CTEST=$P($G(^AUPNVLAB(C0CDA,0)),"^"),X=$P($G(^LAB(60,C0CTEST,64)),"^",2)
    90         . I X S C0CTEST(64)=$P($G(^LAM(X,0)),"^",2)
    91         . S C0CPTEST=$P($G(^AUPNVLAB(C0CPDA,0)),"^"),X=$P($G(^LAB(60,C0CPTEST,64)),"^")
    92         . I X S C0CPTEST(64)=$P($G(^LAM(X,0)),"^",2)
    93         . S ^TMP("C0C-VLAB",$J,1,C0CDA)=""
    94         . I C0CDA'=C0CPDA S ^TMP("C0C-VLAB",$J,1,C0CPDA)=""
    95         . S ^TMP("C0C-VLAB",$J,2,LRDFN,LRSS,LRIDT,LRSB)=C0CPTEST(64)_"^"_C0CTEST(64)_"^"_C0CLN_"^"_C0CDA_"^"_C0CTEST_"^"_C0CPDA_"^"_C0CPTEST
    96         ;
    97         S X=$P(LA7X,"^",3)
    98         ; If order NLT then update if no order NLT
    99         I C0CPTEST(64),$P(X,"!")="" S $P(X,"!")=C0CPTEST(64)
    100         ;
    101         ; If result NLT then update if no result NLT
    102         I C0CTEST(64),$P(X,"!",2)="" S $P(X,"!",2)=C0CTEST(64)
    103         ;
    104         ; If LOINC found then update variable with LN code
    105         I C0CLN'="",$P(X,"!",3)="" S $P(X,"!",3)=C0CLN
    106         ;
    107         S $P(LA7X,"^",3)=X
    108         ;
    109         Q
    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 ;
    112113TMPCHK  ; Check if LN/NLT codes saved from V LAB file above and use when building OBR/OBX segments
    113         ; Called from LA7VOBX1
    114         ;
    115         N I,X
    116         ;
    117         S X=$G(^TMP("C0C-VLAB",$J,2,LRDFN,LRSS,LRIDT,LRSB))
    118         I X="" Q
    119         F I=1:1:3 I $P(LA7X,"!",I)="",$P(X,"^",I)'="" S $P(LA7X,"!",I)=$P(X,"^",I)
    120         S $P(LA7VAL,"^",3)=LA7X
    121         ;
    122         Q
    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 ;
    125126VCHK1   ; Check the entry in V Lab to determine if it meets criteria
    126         ;
    127         N C0CVLAB,I
    128         ;
    129         F I=0,12 S C0CVLAB(I)=$G(^AUPNVLAB(C0CDA,I))
    130         ;
    131         ; JMC 04/13/09 - Store anything for now that meets date criteria.
    132         D VSTORE
    133         ;
    134         Q
    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 ;
    137138VSTORE  ; Store entry for building in HL7 message when parent is from V LAB file.
    138         ;
    139         N C0CPDA,C0CPTEST
    140         ;
    141         ; Determine parent test to use for OBR segment
    142         S C0CPDA=$P(C0CVLAB(12),"^",8)
    143         I C0CPDA="" S C0CPDA=C0CDA
    144         ;
    145         ; Determine parent test
    146         S C0CPTEST=$P($G(^AUPNVLAB(C0CPDA,0)),"^")
    147         ;
    148         S ^TMP("C0C-VLAB",$J,3,$P(C0CVLAB(0),"^",2),$P(C0CVLAB(12),"^"),C0CPTEST,C0CDA)=C0CPDA
    149         ;
    150         Q
    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 ;
    153154FINDDT  ; Find entry in V LAB for the date/time or one close to it.
    154         ; RPMS stores related specimen entries under the same date/time.
    155         ; Lab file #63 creates unique entries with slightly different times.
    156         ;
    157         S C0CDA=$O(^AUPNVLAB("ALR1",DFN,C0CACC,C0C60,C0CDT,0))
    158         I C0CDA>0 Q
    159         ;
    160         ; If entry found then confirm that specimen type matches.
    161         N C0CDTY
    162         S C0CDTY=$O(^AUPNVLAB("ALR1",DFN,C0CACC,C0C60,0))
    163         I C0CDTY D
    164         . I $P(C0CDT,".")'=$P(C0CDTY,".") Q
    165         . S C0CDA=$O(^AUPNVLAB("ALR1",DFN,C0CACC,C0C60,C0CDTY,0))
    166         . I C0CSPEC'=$P($G(^AUPNVLAB(C0CDA,11)),"^",3) S C0CDA=""
    167         ;
    168         Q
     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 ; CCDCCR/GPL - CCR/CCD PROCESSING FOR LAB RESULTS ; 10/01/08
    2  ;;0.3;CCDCCR;nopatch;noreleasedate
     1C0CALABS        ; CCDCCR/GPL - CCR/CCD PROCESSING FOR LAB RESULTS ; 10/01/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    1919 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    2020           ;
    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
     21MAP(MIXML,DFN,MOXML)    ;TO MAKE THIS COMPATIBLE WITH OLD CALLING FOR EXTRACT
    2322 ; ASSUMES THAT EXTRACT HAS BEEN RUN AND THE VARIABLES STORED IN MIVAR
    2423 ; MIXML,MIVAR, AND MOXML ARE PASSED BY NAME
     
    3837 Q
    3938 ;
    40 RPCMAP(RTN,DFN,RMIVAR,RMIXML) ; RPC ENTRY POINT FOR MAPPING RESULTS
     39RPCMAP(RTN,DFN,RMIVAR,RMIXML)   ; RPC ENTRY POINT FOR MAPPING RESULTS
    4140 ; RTN IS PASSED BY REFERENCE
    4241 ;N C0CT0,C0CT,C0CV ; CCR TEMPLATE, RESULTS SUBTEMPLATE, VARIABLES
     
    115114 Q
    116115 ;
    117 EXTRACT(ILXML,DFN,OLXML) ; EXTRACT LABS INTO THE C0CLVAR GLOBAL
     116EXTRACT(ILXML,DFN,OLXML)        ; EXTRACT LABS INTO THE C0CLVAR GLOBAL
    118117 ;
    119118 ; LABXML AND LABOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
     
    136135 Q
    137136     ;
    138 GHL7 ; GET HL7 MESSAGE FOR LABS FOR THIS PATIENT
     137GHL7    ; GET HL7 MESSAGE FOR LABS FOR THIS PATIENT
    139138 ; N C0CPTID,C0CSPC,C0CSDT,C0CEDT,C0CR
    140139 ; SET UP FOR LAB API CALL
     
    156155 Q
    157156 ;
    158 LIST ; LIST THE HL7 MESSAGE; ALSO, EXTRACT THE RESULT VARIABLES TO C0CLB
     157LIST    ; LIST THE HL7 MESSAGE; ALSO, EXTRACT THE RESULT VARIABLES TO C0CLB
    159158 ;
    160159 ; N C0CI,C0CJ,C0COBT,C0CHB,C0CVAR
     
    230229 ;M ^TMP("C0CRIM","VARS",DFN,"RESULTS")=@C0CLB
    231230 Q
    232 LTYP(OSEG,OTYP,OVARA,OC0CQT) ;
     231LTYP(OSEG,OTYP,OVARA,OC0CQT)    ;
    233232 S OTAB=$NA(@C0CTAB@(OTYP)) ; TABLE FOR SEGMENT TYPE
    234233 I '$D(OC0CQT) S C0CQT=0 ; NOT C0CQT IS DEFAULT
     
    247246 . . . I OV'="" W OI_": "_$P(@OTAB@(OI),"^",3),": ",OVAR,": ",OV,!
    248247 Q
    249 LOBX ;
    250  Q
    251  ;
    252 OUT(DFN) ; WRITE OUT A CCR THAT HAS JUST BEEN PROCESSED (FOR TESTING)
     248LOBX    ;
     249 Q
     250 ;
     251OUT(DFN)        ; WRITE OUT A CCR THAT HAS JUST BEEN PROCESSED (FOR TESTING)
    253252 N GA,GF,GD
    254253 S GA=$NA(^TMP("C0CCCR",$J,DFN,"CCR",1))
     
    258257 Q
    259258 ;
    260 SETTBL ;
     259SETTBL  ;
    261260 K X ; CLEAR X
    262261 S X("PID","PID1")="1^00104^Set ID - Patient ID"
  • ccr/trunk/p/C0CMED.m

    r426 r508  
    11C0CMED  ; WV/CCDCCR/GPL/SMH - CCR/CCD Medications Driver; Mar 23 2009
    2         ;;0.6;CCDCCR;;JUL 16,2008;
    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
     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
    2727EXTRACT(MEDXML,DFN,MEDOUTXML)   ; Private; Extract medications into provided XML template
    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
     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
    5555RPMS   
    56         D EXTRACT^C0CMED6(MEDXML,DFN,MEDOUTXML,C0CMFLAG) QUIT
     56 D EXTRACT^C0CMED6(MEDXML,DFN,MEDOUTXML,C0CMFLAG) QUIT
    5757VISTA   
    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        
     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  
    11C0CMED1 ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS ;01/10/09
    2         ;;0.1;CCDCCR;;JUL 16,2008;
    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         ;
     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 ;
    2424EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT,FLAGS)       ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
    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         ;
     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  
    11C0CMED2 ; WV/CCDCCR/SMH - CCR/CCD Meds - Pending for Vista
    2         ;;0.1;CCDCCR;;JUL 16,2008;
    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         ;
     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 ;
    2424EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT)               ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
    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         ;
     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 ; WV/CCDCCR/SMH - Meds: Non-VA/Outside Meds for Vista
    2  ;;0.1;CCDCCR;;;
     1C0CMED3 ; WV/CCDCCR/SMH - Meds: Non-VA/Outside Meds for Vista
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;;Last Modified: Sun Jan 11 05:45:03 UTC 2009
    44 ; Copyright 2009 WorldVistA.  Licensed under the terms of the GNU
     
    2222 Q
    2323 ;
    24 EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; Extract medications into provided xml template
     24EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT)     ; Extract medications into provided xml template
    2525 ;
    2626 ; MINXML is the Input XML Template, (passed by name)
  • ccr/trunk/p/C0CMED6.m

    r424 r508  
    11C0CMED6 ; WV/CCDCCR/SMH - Meds from RPMS: Outpatient Meds;01/10/09
    2         ;;0.1;CCDCCR;;JUL 16,2008;
    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         ;
     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 ;
    2323EXTRACT(MINXML,DFN,OUTXML,FLAGS)         ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
    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         ;
     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 ;
    306306GETRXN(NDC)     ; Extrinsic Function; PUBLIC; NDC to RxNorm
    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        
     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  
    11C0CPARMS        ; CCDCCR/GPL - CCR/CCD PARAMETER PROCESSING ; 1/29/09
    2  ;;0.3;CCDCCR;nopatch;noreleasedate
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008 WorldVistA.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
  • ccr/trunk/p/C0CPROBS.m

    r396 r508  
    1 C0CPROBS ; CCDCCR/GPL - CCR/CCD PROCESSING FOR PROBLEMS ; 6/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate;Build 7
     1C0CPROBS        ; CCDCCR/GPL - CCR/CCD PROCESSING FOR PROBLEMS ; 6/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2222 ; PROCESS THE PROBLEMS SECTION OF THE CCR
    2323 ;
    24 EXTRACT(IPXML,DFN,OUTXML) ; EXTRACT PROBLEMS INTO PROVIDED XML TEMPLATE
     24EXTRACT(IPXML,DFN,OUTXML)       ; EXTRACT PROBLEMS INTO PROVIDED XML TEMPLATE
    2525 ;
    2626 ; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
  • ccr/trunk/p/C0CRIMA.m

    r437 r508  
    1 C0CRIMA   ; CCDCCR/GPL - RIM REPORT ROUTINES; 6/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CRIMA   ; CCDCCR/GPL - RIM REPORT ROUTINES; 6/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota.
    44 ;Licensed under the terms of the GNU General Public License.
     
    3737 ;
    3838 ;
    39 ANALYZE(BEGDFN,DFNCNT,APARMS) ; RIM COHERANCE ANALYSIS ROUTINE
     39ANALYZE(BEGDFN,DFNCNT,APARMS)   ; RIM COHERANCE ANALYSIS ROUTINE
    4040    ; BEGINS AT BEGDFN AND GOES FOR DFNCNT PATIENTS
    4141    ; TO RESUME AT NEXT PATIENT, USE BEGDFN=""
     
    108108    Q
    109109    ;
    110 SETATTR(SDFN) ; SET ATTRIBUTES BASED ON VARS
     110SETATTR(SDFN)   ; SET ATTRIBUTES BASED ON VARS
    111111    N SBASE,SATTR
    112112    S SBASE=$NA(@RIMBASE@("VARS",SDFN))
     
    150150    Q SATTR
    151151    ;
    152 RESET ; KILL RESUME INDICATOR TO START OVER. ALSO KILL RIM TMP VALUES
     152RESET   ; KILL RESUME INDICATOR TO START OVER. ALSO KILL RIM TMP VALUES
    153153    K ^TMP("C0CRIM","RESUME")
    154154    K ^TMP("C0CRIM")
    155155    Q
    156156    ;
    157 CLIST ; LIST THE CATEGORIES
     157CLIST   ; LIST THE CATEGORIES
    158158    ;
    159159    I '$D(RIMBASE) D ASETUP ; FOR COMMAND LINE CALLS
     
    169169    Q
    170170    ;
    171 CPUSH(CATRTN,CBASE,CTBL,CDFN,CATTR) ; ADD PATIENTS TO CATEGORIES
     171CPUSH(CATRTN,CBASE,CTBL,CDFN,CATTR)     ; ADD PATIENTS TO CATEGORIES
    172172    ; AND PASS BACK THE NAME OF THE CATEGORY TO WHICH THE PATIENT
    173173    ; WAS ADDED IN CATRTN, WHICH IS PASSED BY REFERENCE
     
    205205    Q
    206206    ;
    207 CHKSUM(CKDFN) ; DOES A CHECKSUM AND STORES IT IN MUMPS GLOBALS
     207CHKSUM(CKDFN)   ; DOES A CHECKSUM AND STORES IT IN MUMPS GLOBALS
    208208 ;
    209209 S C0CCKB=$NA(^TMP("C0CRIM","CHKSUM")) ;CHECKSUM BASE
     
    230230 Q CHKR
    231231 ;
    232 CCOUNT ; RECOUNT THE CATEGORIES.. USE IN CASE OF RESTART OF ANALYZE
     232CCOUNT  ; RECOUNT THE CATEGORIES.. USE IN CASE OF RESTART OF ANALYZE
    233233    ;
    234234    I '$D(RIMBASE) D ASETUP ; FOR COMMAND LINE CALLS
     
    252252    Q
    253253    ;
    254 CNTLST(INLST) ; RETURNS THE NUMBER OF ELEMENTS IN THE LIST
     254CNTLST(INLST)   ; RETURNS THE NUMBER OF ELEMENTS IN THE LIST
    255255    ; INLST IS PASSED BY NAME
    256256    N ZI,ZDX,ZCOUNT
     
    264264    Q ZCOUNT
    265265    ;
    266 XCPAT(CPATCAT,CPATPARM) ; EXPORT TO FILE ALL PATIENTS IN CATEGORY CPATCAT
     266XCPAT(CPATCAT,CPATPARM) ; EXPORT TO FILE ALL PATIENTS IN CATEGORY CPATCAT
    267267    ;
    268268    I '$D(CPATPARM) S CPATPARM=""
     
    276276    Q
    277277    ;
    278 CPAT(CPATCAT) ; SHOW PATIENT DFNS FOR A CATEGORY CPATCAT
     278CPAT(CPATCAT)   ; SHOW PATIENT DFNS FOR A CATEGORY CPATCAT
    279279    ;
    280280    I '$D(RIMBASE) D ASETUP ; FOR COMMAND LINE CALLS
     
    292292    Q
    293293    ;
    294 PATC(DFN) ; DISPLAY THE CATEGORY FOR THIS PATIENT
     294PATC(DFN)       ; DISPLAY THE CATEGORY FOR THIS PATIENT
    295295    ;
    296296    N ATTR S ATTR=""
     
    305305    Q
    306306    ;
    307 APUSH(AMAP,AVAL) ; ADD AVAL TO ATTRIBUTE MAP AMAP (AMAP PASSED BY NAME)
     307APUSH(AMAP,AVAL)        ; ADD AVAL TO ATTRIBUTE MAP AMAP (AMAP PASSED BY NAME)
    308308    ; AMAP IS FORMED FOR ARRAY ACCESS: AMAP(0) IS THE COUNT
    309309    ; AND AMAP(N)=AVAL IS THE NTH AVAL
     
    320320    Q
    321321    ;
    322 ASETUP ; SET UP GLOBALS AND VARS RIMBASE AND RIMTBL
     322ASETUP  ; SET UP GLOBALS AND VARS RIMBASE AND RIMTBL
    323323      I '$D(RIMBASE) S RIMBASE=$NA(^TMP("C0CRIM"))
    324324      I '$D(@RIMBASE) S @RIMBASE=""
     
    327327      Q
    328328      ;
    329 AINIT ; INITIALIZE ATTRIBUTE TABLE
     329AINIT   ; INITIALIZE ATTRIBUTE TABLE
    330330      I '$D(RIMBASE) D ASETUP ; FOR COMMAND LINE CALLS
    331331      K @RIMTBL
     
    358358      Q
    359359      ;
    360 APOST(PRSLT,PTBL,PVAL) ; POST AN ATTRIBUTE PVAL TO PRSLT USING PTBL
     360APOST(PRSLT,PTBL,PVAL)  ; POST AN ATTRIBUTE PVAL TO PRSLT USING PTBL
    361361    ; PSRLT AND PTBL ARE PASSED BY NAME. PVAL IS A STRING
    362362    ; PTBL IS THE NAME OF A TABLE IN @RIMBASE@("TABLES") - "RIMTBL"=ALL VALUES
     
    369369    S $P(@PRSLT,U,@USETBL@(PVAL))=PVAL
    370370    Q
    371 GETPA(RTN,DFN,ISEC,IVAR) ; RETURNS ARRAY OF RIM VARIABLES FOR PATIENT DFN
     371GETPA(RTN,DFN,ISEC,IVAR)        ; RETURNS ARRAY OF RIM VARIABLES FOR PATIENT DFN
    372372    ; EXAMPLE: D GETPA(.RT,2,"MEDS","MEDSSTATUSTEXT")
    373373    ; RETURNS AN ARRAY RT OF VALUES OF MEDSTATUSTEXT FOR PATIENT 2 IN P2
     
    392392    Q
    393393    ;
    394 PATD(DFN,ISEC,IVAR) ; DISPLAY FOR PATIENT DFN THE VARIABLE IVAR
     394PATD(DFN,ISEC,IVAR)     ; DISPLAY FOR PATIENT DFN THE VARIABLE IVAR
    395395    ;
    396396    N ZR
     
    400400    Q
    401401    ;
    402 CAGET(RTN,IATTR) ;
     402CAGET(RTN,IATTR)        ;
    403403    ; GETPA LOOKS AT RIMTBL TO FIND PATIENTS WITH ATTRIBUTE IATTR
    404404    ; IT DOES NOT SEARCH ALL PATIENTS, ONLY THE ONES WITH THE ATTRIBUTE
     
    406406    Q
    407407    ;
    408 PCLST(LSTRTN,IATTR) ; RETURNS ARRAY OF PATIENTS WITH ATTRIBUTE IATTR
     408PCLST(LSTRTN,IATTR)     ; RETURNS ARRAY OF PATIENTS WITH ATTRIBUTE IATTR
    409409    ;
    410410    I '$D(RIMBASE) D AINIT ; INITIALIZE GLOBAL NAMES AND TABLES
     
    431431    Q
    432432    ;
    433 DCPAT(CATTR) ; DISPLAY LIST OF PATIENTS WITH ATTRIBUTE CATTR
     433DCPAT(CATTR)    ; DISPLAY LIST OF PATIENTS WITH ATTRIBUTE CATTR
    434434    ;
    435435    N ZR
     
    442442    Q
    443443    ;
    444 RPCGV(RTN,DFN,WHICH) ; RPC GET VARS
     444RPCGV(RTN,DFN,WHICH)    ; RPC GET VARS
    445445 ; RETURNS IN RTN (PASSED BY REFERENCE) THE VARS AND VALUES
    446446 ; FOUND AT INARY RTN(X)="VAR^VALUE" RTN(0) IS THE COUNT
     
    460460 Q
    461461 ;
    462 ZGVWRK(ZWHICH) ; DO ONE SECTION FOR RPCGV
     462ZGVWRK(ZWHICH)  ; DO ONE SECTION FOR RPCGV
    463463    ;
    464464    N ZZGN ; NAME FOR SECTION VARIABLES
     
    477477    Q
    478478    ;
    479 DPATV(DFN,IWHICH) ; DISPLAY VARS FOR PATIENT DFN THAT ARE MAINTAINED IN C0CRIM
     479DPATV(DFN,IWHICH)       ; DISPLAY VARS FOR PATIENT DFN THAT ARE MAINTAINED IN C0CRIM
    480480    ; ALONG WITH SAMPLE VALUES.
    481481    ; IWHICH IS "ALL","MEDS","VITALS","PROBLEMS","ALERTS","RESULTS","HEADER"
     
    488488    Q
    489489    ;
    490 RIM2RNF(R2RTN,DFN,RWHICH) ; CONVERTS RIM VARIABLES TO RNF2 FORMAT
     490RIM2RNF(R2RTN,DFN,RWHICH)       ; CONVERTS RIM VARIABLES TO RNF2 FORMAT
    491491 ; RETURN IN R2RTN, WHICH IS PASSED BY NAME
    492492 ; RWHICH IS RIM SECTION TO RETURN, DEFAULTS TO "ALL"
     
    514514 Q
    515515 ;
    516 RIM2CSV(DFN) ; WRITE THE RIM VARIABLES FOR A PATIENT TO A CSV FILE
     516RIM2CSV(DFN)    ; WRITE THE RIM VARIABLES FOR A PATIENT TO A CSV FILE
    517517 ;
    518518 N R2CTMP,R2CARY
  • ccr/trunk/p/C0CRNF.m

    r431 r508  
    1 C0CRNF   ; CCDCCR/GPL - Reference Name Format (RNF) utilities; 12/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CRNF    ; CCDCCR/GPL - Reference Name Format (RNF) utilities; 12/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2009 George Lilly.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    2222 Q
    2323 ;
    24 FIELDS(C0CFRTN,C0CF) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,
     24FIELDS(C0CFRTN,C0CF)    ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,
    2525 ; C0CFRTN IS PASSED BY NAME, C0CF IS PASSED BY VALUE
    2626 ;
     
    4444 Q
    4545 ;
    46 GETNOLD(GRTN,GFILE,GIEN,GNN) ; GET FIELDS FOR ACCESS BY NAME
     46GETNOLD(GRTN,GFILE,GIEN,GNN)    ; GET FIELDS FOR ACCESS BY NAME
    4747 ; GRTN IS PASSED BY NAME
    4848 ;
     
    7070 Q
    7171 ;
    72 GETN(GRTN,GFILE,GREF,GNDX,GNN) ; GET BY NAME ; RETURN A FIELD VALUE MAP
     72GETN(GRTN,GFILE,GREF,GNDX,GNN)  ; GET BY NAME ; RETURN A FIELD VALUE MAP
    7373 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
    7474 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
     
    134134 Q
    135135 ;
    136 GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
     136GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
    137137 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
    138138 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
     
    198198 Q
    199199 ;
    200 GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES
     200GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN)     ; RETURN FIELD MAP AND VALUES
    201201 ; GARTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
    202202 ; .. FIELD MAP @GARTN@("F","FIELDNAME")="FILE;FIELD#"
     
    232232 Q
    233233 ;
    234 ADDNV(GNV,GNVN,GNVF,GNVV) ; CREATE AN ELEMENT OF THE MATRIX
     234ADDNV(GNV,GNVN,GNVF,GNVV)       ; CREATE AN ELEMENT OF THE MATRIX
    235235 ;
    236236 S @GNV@("F",GNVF)=$P(GNVV,"^",1)_"^"_$P(GNVV,"^",2) ;NAME=FILE^FIELD#
     
    238238 Q
    239239 ;
    240 RNF2CSV(RNRTN,RNIN,RNSTY) ;CONVERTS AN RFN2 GLOBAL TO A CSV FORMAT
     240RNF2CSV(RNRTN,RNIN,RNSTY)       ;CONVERTS AN RFN2 GLOBAL TO A CSV FORMAT
    241241 ; READY TO WRITE FOR USE WITH EXCEL @RNRTN@(0) IS NUMBER OF LINES
    242242 ; RNSTY IS STYLE OF THE OUTPUT -
     
    251251 Q
    252252 ;
    253 NV(RNRTN,RNIN) ;
     253NV(RNRTN,RNIN)  ;
    254254 S RNR=$NA(@RNIN@("F"))
    255255 S RNC=$NA(@RNIN@("V"))
     
    273273 Q
    274274 ;
    275 VN(RNRTN,RNIN) ;
     275VN(RNRTN,RNIN)  ;
    276276 S RNR=$NA(@RNIN@("V"))
    277277 S RNC=$NA(@RNIN@("F"))
     
    295295 Q
    296296 ;
    297 FILE2CSV(FNUM,FVN) ; WRITES OUT A FILEMAN FILE TO CSV
     297FILE2CSV(FNUM,FVN)      ; WRITES OUT A FILEMAN FILE TO CSV
    298298 ;
    299299 ;N G1,G2
     
    308308 Q
    309309 ;
    310 FILEOUT(FOARY,FONAM) ; WRITE OUT A FILE
     310FILEOUT(FOARY,FONAM)    ; WRITE OUT A FILE
    311311 ;
    312312 W $$OUTPUT^GPLXPATH($NA(@FOARY@(1)),FONAM,^TMP("GPLCCR","ODIR"))
    313313 Q
    314314 ;
    315 FILEREF(FNUM) ; EXTRINSIC THAT RETURNS A CLOSED ROOT FOR FILE NUMBER FNUM
     315FILEREF(FNUM)   ; EXTRINSIC THAT RETURNS A CLOSED ROOT FOR FILE NUMBER FNUM
    316316 ;
    317317 N C0CF
     
    321321 Q C0CF
    322322 ;
    323 SKIP ;
     323SKIP    ;
    324324 N TXT,DIERR
    325325 S TXT=$$GET1^DIQ(8925,TIUIEN,"2","","TXT")
     
    332332 Q
    333333 ;
    334 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
     334ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
    335335 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF @ZTAB@(ZFN)
    336336 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
    337337 I '$D(ZTAB) S ZTAB="C0CA"
    338338 Q $P(@ZTAB@(ZFN),"^",1)
    339 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
     339ZFIELD(ZFN,ZTAB)        ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
    340340 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF @ZTAB@(ZFN)
    341341 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
    342342 I '$D(ZTAB) S ZTAB="C0CA"
    343343 Q $P(@ZTAB@(ZFN),"^",2)
    344 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
     344ZVALUE(ZFN,ZTAB)        ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
    345345 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF @ZTAB@(ZFN)
    346346 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    348348 Q $P($G(@ZTAB@(ZFN)),"^",3)
    349349 ;
    350 ZVALUEI(ZFN,ZTAB) ;EXTRINSIC TO RETURN INTERNAL VALUE FOR FIELD NAME PASSED
     350ZVALUEI(ZFN,ZTAB)       ;EXTRINSIC TO RETURN INTERNAL VALUE FOR FIELD NAME PASSED
    351351 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF @ZTAB@(ZFN)
    352352 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
  • ccr/trunk/p/C0CRXN.m

    r404 r508  
    1 C0CRXN   ; CCDCCR/GPL - CCR RXN utilities; 12/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CRXN    ; CCDCCR/GPL - CCR RXN utilities; 12/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2009 George Lilly.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    2222 Q
    2323 ;
    24 EXPAND ; MAIN ROUTINE TO CREATE THE C0C RXNORM VUID EXPANSION FILE (176.112)
     24EXPAND  ; MAIN ROUTINE TO CREATE THE C0C RXNORM VUID EXPANSION FILE (176.112)
    2525 ; READ EACH RECORD FROM 176.111 AND USE THE VUID TO LOOK UP THE RXNORM
    2626 ; CODE FROM 176.001 (RXNORM CONCEPTS)
     
    8383 Q
    8484 ;
    85 EXP2 ; ROUTINE TO CREATE 176.113 C0C RXNORM VUID MAPPING DISCREPANCIES FILE
     85EXP2    ; ROUTINE TO CREATE 176.113 C0C RXNORM VUID MAPPING DISCREPANCIES FILE
    8686 ; CROSS CHECKS THE NATIONAL DRUG FILE AND THE VA MAPPING FILE AGAINST
    8787 ; THE UMLS RXNORM DATABASE
     
    158158 W "NDF TEXT MISMATCH: ",NDFTCNT,!
    159159 Q
    160 CHKNDF ; ROUTINE TO CHECK THE NATIONAL DRUG FILE WITH THE UMLS RXNORM DB
     160CHKNDF  ; ROUTINE TO CHECK THE NATIONAL DRUG FILE WITH THE UMLS RXNORM DB
    161161 ; USING THE AVUID INDEX, READS ALL VUID CODES IN ^PSNDF(50.68),
    162162 ; CHECKS TO SEE IF THE CODE IS IN 176.001, AND CREATES A RECORD
     
    253253 W "TEXT MATCHES:",TXTMATCH,!
    254254 Q
    255 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
     255SETFDA(C0CSN,C0CSV)     ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
    256256 ; TO SET TO VALUE C0CSV.
    257257 ; C0CFDA,C0CA,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE
     
    263263 S C0CFDA(C0CSI,"+"_C0CZX_",",C0CSJ)=C0CSV
    264264 Q
    265 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
     265ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
    266266 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
    267267 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    271271 E  S ZR=""
    272272 Q ZR
    273 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
     273ZFIELD(ZFN,ZTAB)        ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
    274274 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
    275275 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    280280 Q ZR
    281281 ;
    282 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
     282ZVALUE(ZFN,ZTAB)        ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
    283283 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
    284284 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
  • ccr/trunk/p/C0CSUB1.m

    r436 r508  
    1 C0CSUB1   ; CCDCCR/GPL - CCR SUBSCRIPTION utilities; 12/6/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CSUB1   ; CCDCCR/GPL - CCR SUBSCRIPTION utilities; 12/6/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2009 George Lilly.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    2121 Q
    2222 ;
    23 CHK1(DFN) ; ADD THE CHECKSUM FOR ONE PATIENT
     23CHK1(DFN)       ; ADD THE CHECKSUM FOR ONE PATIENT
    2424 ;
    2525 S C0CCHK=$NA(^TMP("C0CRIM","CHKSUM"))
     
    4343 Q
    4444 ;
    45 SUBALL ; SUBSCRIBE ALL PATIENTS IN CCR GLOBALS TO SUBCRIBER 1
     45SUBALL  ; SUBSCRIBE ALL PATIENTS IN CCR GLOBALS TO SUBCRIBER 1
    4646 ;
    4747 S C0CGLB=$NA(^TMP("C0CRIM","VARS"))
     
    5151 Q
    5252 ;
    53 SUB1(DFN,C0CSS) ; SUBSCRIBE ONE PATIENT TO SUBSCRIBER C0CSS
     53SUB1(DFN,C0CSS) ; SUBSCRIBE ONE PATIENT TO SUBSCRIBER C0CSS
    5454 ;
    5555 S C0CSF=177.101 ; FILE NUMBER FOR SUBSCRIPTION FILE
     
    6666 Q
    6767 ;
    68 UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
     68UPDIE   ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
    6969 K ZERR
    7070 D CLEAN^DILF
     
    7777 Q
    7878 ;
    79 VARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
     79VARPTR(ZVAR,ZTYP)       ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
    8080 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO
    8181 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO
     
    9999 Q ZVARN
    100100 ;
    101 SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
     101SETFDA(C0CSN,C0CSV)     ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
    102102 ; TO SET TO VALUE C0CSV.
    103103 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE
     
    109109 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV
    110110 Q
    111 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
     111ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
    112112 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
    113113 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    117117 E  S ZR=""
    118118 Q ZR
    119 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
     119ZFIELD(ZFN,ZTAB)        ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
    120120 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
    121121 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
     
    126126 Q ZR
    127127 ;
    128 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
     128ZVALUE(ZFN,ZTAB)        ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
    129129 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
    130130 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
  • ccr/trunk/p/C0CSYS.m

    r399 r508  
    1 C0CSYS ;WV/C0C/SMH - Routine to Get EHR System Information;6JUL2008
    2  ;;0.1;C0C;;;
     1C0CSYS  ;WV/C0C/SMH - Routine to Get EHR System Information;6JUL2008
     2 ;;1.0;C0C;;May 19, 2009;
    33 ; Copyright 2008 WorldVistA.  Licensed under the terms of the GNU
    44 ; General Public License See attached copy of the License.
     
    2727 ; So for now, I am hard-coding the values.
    2828 ;
    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          ;
     29SYSNAME()       ;Get EHR System Name; PUBLIC; Extrinsic
     30 Q:$G(DUZ("AG"))="I" "RPMS"
     31 Q "WorldVistA EHR/VOE"
     32 ;
     33SYSVER()        ;Get EHR System Version; PUBLIC; Extrinsic
     34 Q "1.0"
     35 ;
     36PTST(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 ; CCDCCR/GPL - Unit Testing Library; 5/07/08
    2  ;;0.1;CCDCCR;nopatch;noreleasedate
     1C0CUNIT ; CCDCCR/GPL - Unit Testing Library; 5/07/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008 George Lilly. Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    2222          Q
    2323          ;
    24 ZT(ZARY,BAT,TST) ; private routine to add a test case to the ZARY array
     24ZT(ZARY,BAT,TST)        ; private routine to add a test case to the ZARY array
    2525          ; ZARY IS PASSED BY REFERENCE
    2626          ; BAT is a string identifying the test battery
     
    4545          Q
    4646          ;
    47 ZLOAD(ZARY,ROUTINE)  ; load tests into ZARY which is passed by reference
     47ZLOAD(ZARY,ROUTINE)      ; load tests into ZARY which is passed by reference
    4848          ; ZARY IS PASSED BY NAME
    4949          ; ZARY = name of the root, closed array format (e.g., "^TMP($J)")
     
    6868          Q
    6969          ;
    70 ZTEST(ZARY,WHICH)   ; try out the tests using a passed array ZTEST
     70ZTEST(ZARY,WHICH)         ; try out the tests using a passed array ZTEST
    7171          N ZI,ZX,ZR,ZP
    7272          S DEBUG=0
     
    104104          Q
    105105          ;
    106 TEST   ; RUN ALL THE TEST CASES
     106TEST      ; RUN ALL THE TEST CASES
    107107          N ZTMP
    108108          D ZLOAD(.ZTMP)
     
    115115          Q
    116116          ;
    117 GTSTS(GTZARY,RTN) ; return an array of test names
     117GTSTS(GTZARY,RTN)       ; return an array of test names
    118118          N I,J S I="" S I=$O(GTZARY("TESTS",I))
    119119          F J=0:0  Q:I=""  D
     
    122122          Q
    123123          ;
    124 TESTALL(RNM) ; RUN ALL THE TESTS
     124TESTALL(RNM)    ; RUN ALL THE TESTS
    125125          N ZI,J,TZTMP,TSTS,TOTP,TOTF
    126126          S TOTP=0 S TOTF=0
     
    141141          Q
    142142          ;
    143 TLIST(ZARY) ; LIST ALL THE TESTS
     143TLIST(ZARY)     ; LIST ALL THE TESTS
    144144          ; THEY ARE MARKED AS ;;><TESTNAME> IN THE TEST CASES
    145145          ; ZARY IS PASSED BY REFERENCE
     
    155155          Q
    156156          ;
    157 MEDS
     157MEDS   
    158158 N DEBUG S DEBUG=0
    159159 N DFN S DFN=5685
     
    172172 D FILEOUT^C0CRNF(OUTXML,"TESTMEDS.xml")
    173173 Q
    174 PAT
     174PAT     
    175175 D ANALYZE^ARJTXRD("C0CDPT",.OUT) ; Analyze a routine in the directory
    176176 N X,Y
  • ccr/trunk/p/C0CUTIL.m

    r421 r508  
    11C0CUTIL ;WV/C0C/SMH - Various Utilites for generating the CCR/CCD;06/15/08
    2         ;;0.1;C0C;;Jun 15, 2008;
    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         ;
     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 ;
    2424FMDTOUTC(DATE,FORMAT)   ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrinsic
    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         ;
     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 ;
    6060SORTDT(V1,V2,ORDR)      ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT
    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         ;
     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 ;
    9191DA2SNO(RTN,DNAME)       ; LOOK UP DRUG ALLERGY CODE IN ^LEX
    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         ;
     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 ;
    106106DASNO(DANAME)   ; PRINTS THE SNOMED CODE FOR ALLERGY TO DRUG DANAME
    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         ;
     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 ;
    115115DASNALL(WHICH)  ; ROUTINE TO EXAMINE THE ADIS INDEX IN LEX AND RETRIEVE ALL
    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         ;
     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 ;
    125125RPMS()  ; Are we running on an RPMS system rather than Vista?
    126         Q $G(DUZ("AG"))="I" ; If User Agency is Indian Health Service
     126 Q $G(DUZ("AG"))="I" ; If User Agency is Indian Health Service
    127127VISTA() ; Are we running on Vanilla Vista?
    128         Q $G(DUZ("AG"))="V" ; If User Agency is VA
     128 Q $G(DUZ("AG"))="V" ; If User Agency is VA
    129129WV()    ; Are we running on WorldVista?
    130         Q $G(DUZ("AG"))="E" ; Code for WV.
     130 Q $G(DUZ("AG"))="E" ; Code for WV.
    131131OV()    ; Are we running on OpenVista?
    132         Q $G(DUZ("AG"))="O" ; Code for OpenVista
     132 Q $G(DUZ("AG"))="O" ; Code for OpenVista
  • ccr/trunk/p/C0CVA200.m

    r397 r508  
    1 C0CVA200 ;WV/C0C/SMH - Routine to get Provider Data;07/13/2008
    2         ;;0.1;C0C;;JUL 13, 2007;Build 0
     1C0CVA200        ;WV/C0C/SMH - Routine to get Provider Data;07/13/2008
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008 Sam Habiel.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    1717 ;with this program; if not, write to the Free Software Foundation, Inc.,
    1818 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    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^Sub­specialty^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         ;
     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  ;
     25FAMILY(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  ;
     32GIVEN(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  ;
     39MIDDLE(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  ;
     46SUFFIX(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  ;
     53TITLE(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  ;
     61NPI(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  ;
     73SPEC(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^Sub­specialty^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  ;
     85ADDTYPE(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  ;
     90ADDLINE1(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  ;
     113CITY(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  ;
     126STATE(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  ;
     138POSTCODE(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  ;
     150TEL(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  ;
     157TELTYPE(DUZ)    ; Get Telephone Type. PUBLIC; EXTRINSIC
     158  ; INPUT: DUZ ByVal
     159  ; OUTPUT: String.
     160  Q "Office"
     161  ;
     162EMAIL(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 ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
    2  ;;0.1;CCDCCR;;JUL 16,2008;
     1C0CVITAL        ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008,2009 George Lilly, University of Minnesota and others.
    44 ;Licensed under the terms of the GNU General Public License.
     
    2222 Q
    2323 ;
    24 EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
     24EXTRACT(VITXML,DFN,VITOUTXML)   ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
    2525 ;
    2626 ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
     
    191191 Q
    192192 ;
    193 VITDATES(VDT) ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
     193VITDATES(VDT)   ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
    194194 ; OF DATES IN THE VITALS RESULTS
    195195 N VDTI,VDTJ,VTDCNT
  • ccr/trunk/p/C0CXPAT0.m

    r391 r508  
    1 C0CXPAT0   ; CCDCCR/GPL - XPATH TEST CASES ; 6/1/08
    2  ;;0.2;CCDCCR;nopatch;noreleasedate
     1C0CXPAT0          ; CCDCCR/GPL - XPATH TEST CASES ; 6/1/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008 George Lilly.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
  • ccr/trunk/p/C0CXPATH.m

    r391 r508  
    1 C0CXPATH   ; CCDCCR/GPL - XPATH XML manipulation utilities; 6/1/08
    2  ;;0.2;CCDCCR;nopatch;noreleasedate
     1C0CXPATH          ; CCDCCR/GPL - XPATH XML manipulation utilities; 6/1/08
     2 ;;1.0;C0C;;May 19, 2009;
    33 ;Copyright 2008 George Lilly.  Licensed under the terms of the GNU
    44 ;General Public License See attached copy of the License.
     
    2222 Q
    2323 ;
    24 OUTPUT(OUTARY,OUTNAME,OUTDIR)   ; WRITE AN ARRAY TO A FILE
     24OUTPUT(OUTARY,OUTNAME,OUTDIR)     ; WRITE AN ARRAY TO A FILE
    2525 ;
    2626 N Y
     
    3030 Q
    3131 ;
    32 PUSH(STK,VAL)   ; pushs VAL onto STK and updates STK(0)
     32PUSH(STK,VAL)     ; pushs VAL onto STK and updates STK(0)
    3333 ;  VAL IS A STRING AND STK IS PASSED BY NAME
    3434 ;
     
    3838 Q
    3939 ;
    40 POP(STK,VAL)    ; POPS THE LAST VALUE OFF THE STK AND RETURNS IT IN VAL
     40POP(STK,VAL)       ; POPS THE LAST VALUE OFF THE STK AND RETURNS IT IN VAL
    4141 ; VAL AND STK ARE PASSED BY REFERENCE
    4242 ;
     
    5050 Q
    5151 ;
    52 PUSHA(ADEST,ASRC) ; PUSH ASRC ONTO ADEST, BOTH PASSED BY NAME
     52PUSHA(ADEST,ASRC)       ; PUSH ASRC ONTO ADEST, BOTH PASSED BY NAME
    5353 ;
    5454 N ZGI
     
    5757 Q
    5858 ;
    59 MKMDX(STK,RTN)  ; MAKES A MUMPS INDEX FROM THE ARRAY STK
     59MKMDX(STK,RTN)  ; MAKES A MUMPS INDEX FROM THE ARRAY STK
    6060 ; RTN IS SET TO //FIRST/SECOND/THIRD FOR THREE ARRAY ELEMENTS
    6161 S RTN=""
     
    6868 Q
    6969 ;
    70 XNAME(ISTR)     ; FUNCTION TO EXTRACT A NAME FROM AN XML FRAG
     70XNAME(ISTR)         ; FUNCTION TO EXTRACT A NAME FROM AN XML FRAG
    7171 ;  </NAME> AND <NAME ID=XNAME> WILL RETURN NAME
    7272 ; ISTR IS PASSED BY VALUE
     
    8383 Q CUR
    8484 ;
    85 INDEX(ZXML)     ; parse the XML in ZXML and produce an XPATH index
     85INDEX(ZXML)         ; parse the XML in ZXML and produce an XPATH index
    8686 ; ex. ZXML(FIRST,SECOND,THIRD,FOURTH)=FIRSTLINE^LASTLINE
    8787 ; WHERE FIRSTLINE AND LASTLINE ARE THE BEGINNING AND ENDING OF THE
     
    141141 Q
    142142 ;
    143 QUERY(IARY,XPATH,OARY)  ; RETURNS THE XML ARRAY MATCHING THE XPATH EXPRESSION
     143QUERY(IARY,XPATH,OARY)  ; RETURNS THE XML ARRAY MATCHING THE XPATH EXPRESSION
    144144 ; XPATH IS OF THE FORM "//FIRST/SECOND/THIRD"
    145145 ; IARY AND OARY ARE PASSED BY NAME
     
    163163 Q
    164164 ;
    165 XF(IDX,XPATH)   ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN XPATH
     165XF(IDX,XPATH)     ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN XPATH
    166166 ; INDEX WITH TWO PIECES START^FINISH
    167167 ; IDX IS PASSED BY NAME
    168168 Q $P(@IDX@(XPATH),"^",1)
    169169 ;
    170 XL(IDX,XPATH)   ; EXTRINSIC TO RETURN THE LAST LINE FROM AN XPATH
     170XL(IDX,XPATH)     ; EXTRINSIC TO RETURN THE LAST LINE FROM AN XPATH
    171171 ; INDEX WITH TWO PIECES START^FINISH
    172172 ; IDX IS PASSED BY NAME
    173173 Q $P(@IDX@(XPATH),"^",2)
    174174 ;
    175 START(ISTR)     ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN INDEX
     175START(ISTR)         ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN INDEX
    176176 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
    177177 ; COMPANION TO FINISH ; IDX IS PASSED BY NAME
    178178 Q $P(ISTR,";",2)
    179179 ;
    180 FINISH(ISTR)    ; EXTRINSIC TO RETURN THE LAST LINE FROM AN INDEX
     180FINISH(ISTR)       ; EXTRINSIC TO RETURN THE LAST LINE FROM AN INDEX
    181181 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
    182182 Q $P(ISTR,";",3)
    183183 ;
    184 ARRAY(ISTR)     ; EXTRINSIC TO RETURN THE ARRAY REFERENCE FROM AN INDEX
     184ARRAY(ISTR)         ; EXTRINSIC TO RETURN THE ARRAY REFERENCE FROM AN INDEX
    185185 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
    186186 Q $P(ISTR,";",1)
    187187 ;
    188 BUILD(BLIST,BDEST)      ; A COPY MACHINE THAT TAKE INSTRUCTIONS IN ARRAY BLIST
     188BUILD(BLIST,BDEST)           ; A COPY MACHINE THAT TAKE INSTRUCTIONS IN ARRAY BLIST
    189189 ; WHICH HAVE ARRAY;START;FINISH AND COPIES THEM TO DEST
    190190 ; DEST IS CLEARED TO START
     
    204204 Q
    205205 ;
    206 QUEUE(BLST,ARRAY,FIRST,LAST)    ; ADD AN ENTRY TO A BLIST
     206QUEUE(BLST,ARRAY,FIRST,LAST)       ; ADD AN ENTRY TO A BLIST
    207207 ;
    208208 I DEBUG W "QUEUEING ",BLST,!
     
    210210 Q
    211211 ;
    212 CP(CPSRC,CPDEST)        ; COPIES CPSRC TO CPDEST BOTH PASSED BY NAME
     212CP(CPSRC,CPDEST)               ; COPIES CPSRC TO CPDEST BOTH PASSED BY NAME
    213213 ; KILLS CPDEST FIRST
    214214 N CPINSTR
     
    222222 Q
    223223 ;
    224 QOPEN(QOBLIST,QOXML,QOXPATH)    ; ADD ALL BUT THE LAST LINE OF QOXML TO QOBLIST
     224QOPEN(QOBLIST,QOXML,QOXPATH)       ; ADD ALL BUT THE LAST LINE OF QOXML TO QOBLIST
    225225 ; WARNING NEED TO DO QCLOSE FOR SAME XML BEFORE CALLING BUILD
    226226 ; QOXPATH IS OPTIONAL - WILL OPEN INSIDE THE XPATH POINT
     
    242242 Q
    243243 ;
    244 QCLOSE(QCBLIST,QCXML,QCXPATH)   ; CLOSE XML AFTER A QOPEN
     244QCLOSE(QCBLIST,QCXML,QCXPATH)     ; CLOSE XML AFTER A QOPEN
    245245 ; ADDS THE LIST LINE OF QCXML TO QCBLIST
    246246 ; USED TO FINISH INSERTING CHILDERN NODES
     
    261261 Q
    262262 ;
    263 INSERT(INSXML,INSNEW,INSXPATH)  ; INSERT INSNEW INTO INSXML AT THE
     263INSERT(INSXML,INSNEW,INSXPATH)  ; INSERT INSNEW INTO INSXML AT THE
    264264 ; INSXPATH XPATH POINT INSXPATH IS OPTIONAL - IF IT IS
    265265 ; OMITTED, INSERTION WILL BE AT THE ROOT
     
    287287 Q
    288288 ;
    289 INSINNER(INNXML,INNNEW,INNXPATH)        ; INSERT THE INNER XML OF INNNEW
     289INSINNER(INNXML,INNNEW,INNXPATH)               ; INSERT THE INNER XML OF INNNEW
    290290 ; INTO INNXML AT THE INNXPATH XPATH POINT
    291291 ;
     
    307307 Q
    308308 ;
    309 INSB4(XDEST,XNEW) ; INSERT XNEW AT THE BEGINNING OF XDEST
     309INSB4(XDEST,XNEW)       ; INSERT XNEW AT THE BEGINNING OF XDEST
    310310 ; BUT XDEST AN XNEW ARE PASSED BY NAME
    311311 N XBLD,XTMP
     
    318318 Q
    319319 ;
    320 REPLACE(REXML,RENEW,REXPATH)    ; REPLACE THE XML AT THE XPATH POINT
     320REPLACE(REXML,RENEW,REXPATH)       ; REPLACE THE XML AT THE XPATH POINT
    321321 ; WITH RENEW - NOTE THIS WILL DELETE WHAT WAS THERE BEFORE
    322322 ; REXML AND RENEW ARE PASSED BY NAME XPATH IS A VALUE
     
    342342 Q
    343343 ;
    344 MISSING(IXML,OARY)      ; SEARTH THROUGH INXLM AND PUT ANY @@X@@ VARS IN OARY
     344MISSING(IXML,OARY)           ; SEARTH THROUGH INXLM AND PUT ANY @@X@@ VARS IN OARY
    345345 ; W "Reporting on the missing",!
    346346 ; W OARY
     
    354354 Q
    355355 ;
    356 MAP(IXML,INARY,OXML)    ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY
     356MAP(IXML,INARY,OXML)       ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY
    357357 ; AND PUT THE RESULTS IN OXML
    358358 I '$D(@IXML@(0)) W "MALFORMED XML PASSED TO MAP",! Q
     
    379379 Q
    380380 ;
    381 DOFLD ; PROCESS A FILEMAN FIELD REFERENCED BY A VARIABLE
    382  ;
    383  Q
    384  ;
    385 TRIM(THEXML) ; TAKES OUT ALL NULL ELEMENTS
     381DOFLD   ; PROCESS A FILEMAN FIELD REFERENCED BY A VARIABLE
     382 ;
     383 Q
     384 ;
     385TRIM(THEXML)    ; TAKES OUT ALL NULL ELEMENTS
    386386 ; THEXML IS PASSED BY NAME
    387387 N I,J,TMPXML,DEL,FOUND,INTXT
     
    421421 Q FOUND
    422422 ;
    423 UNMARK(XSEC) ; REMOVE MARKUP FROM FIRST AND LAST LINE OF XML
     423UNMARK(XSEC)    ; REMOVE MARKUP FROM FIRST AND LAST LINE OF XML
    424424 ; XSEC IS A SECTION PASSED BY NAME
    425425 N XBLD,XTMP
     
    429429 Q
    430430 ;
    431 PARY(GLO)       ;PRINT AN ARRAY
     431PARY(GLO)             ;PRINT AN ARRAY
    432432 N I
    433433 F I=1:1:@GLO@(0) W I_" "_@GLO@(I),!
    434434 Q
    435435 ;
    436 H2ARY(IARYRTN,IHASH,IPRE) ; CONVERT IHASH TO RETURN ARRAY
     436H2ARY(IARYRTN,IHASH,IPRE)       ; CONVERT IHASH TO RETURN ARRAY
    437437 ; IPRE IS OPTIONAL PREFIX FOR THE ELEMENTS. USED FOR MUPTIPLES 1^"VAR"^VALUE
    438438 I '$D(IPRE) S IPRE=""
     
    460460 Q
    461461 ;
    462 XVARS(XVRTN,XVIXML) ; RETURNS AN ARRAY XVRTN OF ALL UNIQUE VARIABLES
     462XVARS(XVRTN,XVIXML)     ; RETURNS AN ARRAY XVRTN OF ALL UNIQUE VARIABLES
    463463 ; DEFINED IN INPUT XML XVIXML BY @@VAR@@
    464464 ; XVRTN AND XVIXML ARE PASSED BY NAME
     
    471471 Q
    472472 ;
    473 DXVARS(DXIN) ;DISPLAY ALL VARIABLES IN A TEMPLATE
     473DXVARS(DXIN)    ;DISPLAY ALL VARIABLES IN A TEMPLATE
    474474 ; IF PARAMETERS ARE NULL, DEFAULTS TO CCR TEMPLATE
    475475 ;
     
    487487 Q
    488488 ;
    489 TEST     ; Run all the test cases
     489TEST        ; Run all the test cases
    490490 D TESTALL^C0CUNIT("C0CXPAT0")
    491491 Q
    492492 ;
    493 ZTEST(WHICH)    ; RUN ONE SET OF TESTS
     493ZTEST(WHICH)       ; RUN ONE SET OF TESTS
    494494 N ZTMP
    495495 S DEBUG=1
     
    498498 Q
    499499 ;
    500 TLIST   ; LIST THE TESTS
     500TLIST     ; LIST THE TESTS
    501501 N ZTMP
    502502 D ZLOAD^C0CUNIT("ZTMP","C0CXPAT0")
  • ccr/trunk/p/LA7QRY1.m

    r447 r508  
    11LA7QRY1 ;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  Q
    5  ;
     2        ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,61**;Sep 27, 1994;Build 31
     3        ;
     4        Q
     5        ;
    66CHKSC   ; Check search NLT/LOINC codes
    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  ;
     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        ;
    2323SPEC    ; Convert HL7 Specimen Codes to File #61, Topography codes
    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  ;
     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        ;
    3434BUILDMSG        ; Build HL7 message with result of query
    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  ;
     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        ;
    6363PID     ; Build PID segment
    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  ;
     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        ;
    7676ORC     ; Build ORC segment
    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  ;
     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        ;
    9292OBR     ; Build OBR segment
    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  ;
     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        ;
    108108OBX     ; Build OBX segment
    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
     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.