Refactor of Med Routines, part 1
This commit is contained in:
parent
2bf3550f5d
commit
67d0bf0a72
46
p/C0CMED.m
46
p/C0CMED.m
|
@ -40,30 +40,32 @@ EXTRACT(MEDXML,DFN,MEDOUTXML) ; Private; Extract medications into provided XML t
|
|||
; 6. RPMS Meds are in C0CMED6. Need to create other routines for subdivisions of RPMS Meds is not known at this time.
|
||||
;
|
||||
; --Prep variables
|
||||
D:$$RPMS^C0CUTIL() RPMS QUIT
|
||||
D:($$VISTA^C0CUTIL())!($$WV^C0CUTIL()) VISTA QUIT
|
||||
D EXTRACT^C0CMED1(MEDXML,DFN,MEDOUTXML) ; FIRST EXTRACT OUTPATIENT MEDS
|
||||
I @MEDOUTXML@(0)>0 D ; C0CMED FOUND ACTIVE OP MEDS
|
||||
. W "HAS ACTIVE OP MEDS",!
|
||||
N PENDINGXML
|
||||
S PENDINGXML="MEDPENDING" ;NAME FOR ARRAY
|
||||
D EXTRACT^C0CMED2(MEDXML,DFN,PENDINGXML) ; FIRST EXTRACT OUTPATIENT MEDS
|
||||
I @PENDINGXML@(0)>0 D ; C0CMED FOUND PENDING OP MEDS
|
||||
. I @MEDOUTXML@(0)>0 D ; IF WE NEED TO COMBINE MEDS
|
||||
. . D INSINNER^C0CXPATH(MEDOUTXML,PENDINGXML) ;ADD PENDING TO ACTIVE
|
||||
. E D CP^C0CXPATH(PENDINGXML,MEDOUTXML) ; NO ACTIVE MEDS, JUST COPY
|
||||
. W "HAS OP PENDING MEDS",!
|
||||
N PENDINGXML
|
||||
S PENDINGXML="MEDPENDING" ;NAME FOR ARRAY
|
||||
D EXTRACT^C0CMED3(MEDXML,DFN,PENDINGXML) ; FIRST EXTRACT OUTPATIENT MEDS
|
||||
I @PENDINGXML@(0)>0 D ; C0CMED FOUND PENDING OP MEDS
|
||||
. I @MEDOUTXML@(0)>0 D ; IF WE NEED TO COMBINE MEDS
|
||||
. . D INSINNER^C0CXPATH(MEDOUTXML,PENDINGXML) ;ADD NON-VA TO MEDS
|
||||
. E D CP^C0CXPATH(PENDINGXML,MEDOUTXML) ; NO PREVIOUS MEDS, JUST COPY
|
||||
. W:$G(DEBUG) "HAS NON-VA MEDS",!
|
||||
Q
|
||||
I $$RPMS^C0CUTIL() D RPMS QUIT
|
||||
I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VISTA QUIT
|
||||
; Extraction Sections
|
||||
RPMS
|
||||
D EXTRACT^C0CMED6(MEDXML,DFN,MEDOUTXML) QUIT
|
||||
VISTA
|
||||
N MEDCOUNT S MEDCOUNT=0
|
||||
N HIST S HIST=$NA(^TMP($J,"MED","HIST")) ; Meds already dispensed
|
||||
N PEND S PEND=$NA(^TMP($J,"MED","PEND")) ; Pending Meds
|
||||
N NVA S NVA=$NA(^TMP($J,"MED","NVA")) ; non-VA Meds
|
||||
; N IPIV ; Inpatient IV Meds
|
||||
; N IPUD ; Inpatient UD Meds
|
||||
K ^TMP($J,"MED")
|
||||
D EXTRACT^C0CMED1(MEDXML,DFN,HIST,.MEDCOUNT) ; Historical OP Meds
|
||||
D EXTRACT^C0CMED2(MEDXML,DFN,PEND,.MEDCOUNT) ; Pending Meds
|
||||
D EXTRACT^C0CMED3(MEDXML,DFN,NVA,.MEDCOUNT) ; non-VA Meds
|
||||
I @HIST@(0)>0 D
|
||||
. D CP^C0CXPATH(HIST,MEDOUTXML)
|
||||
. W:$G(DEBUG) "HAS ACTIVE OP MEDS",!
|
||||
I @PEND@(0)>0 D
|
||||
. I @HIST@(0)>0 D INSINNER^C0CXPATH(MEDOUTXML,PEND) ;Add Pending to Historical
|
||||
. E D CP^C0CXPATH(PEND,MEDOUTXML) ; No historical, just copy
|
||||
. W:$G(DEBUG) "HAS OP PENDING MEDS",!
|
||||
I @NVA@(0)>0 D
|
||||
. I @HIST@(0)>0!(@PEND@(0)>0) D INSINNER^C0CXPATH(MEDOUTXML,NVA)
|
||||
. E D CP^C0CXPATH(NVA,MEDOUTXML)
|
||||
. W:$G(DEBUG) "HAS NON-VA MEDS",!
|
||||
Q
|
||||
|
||||
|
|
453
p/C0CMED1.m
453
p/C0CMED1.m
|
@ -1,229 +1,224 @@
|
|||
C0CMED1 ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS ;01/10/09
|
||||
;;0.1;CCDCCR;;JUL 16,2008;
|
||||
;;Last modified Sat Jan 10 21:42:27 PST 2009
|
||||
; Copyright 2009 WorldVistA. Licensed under the terms of the GNU
|
||||
; General Public License See attached copy of the License.
|
||||
;
|
||||
; This program is free software; you can redistribute it and/or modify
|
||||
; it under the terms of the GNU General Public License as published by
|
||||
; the Free Software Foundation; either version 2 of the License, or
|
||||
; (at your option) any later version.
|
||||
;
|
||||
; This program is distributed in the hope that it will be useful,
|
||||
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
; GNU General Public License for more details.
|
||||
;
|
||||
; You should have received a copy of the GNU General Public License along
|
||||
; with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
W "NO ENTRY FROM TOP",!
|
||||
Q
|
||||
;
|
||||
EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
|
||||
;
|
||||
; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
|
||||
; INXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
|
||||
;
|
||||
; MEDS is return array from RPC.
|
||||
; MAP is a mapping variable map (store result) for each med
|
||||
; MED is holds each array element from MEDS(J), one medicine
|
||||
; J is a counter.
|
||||
;
|
||||
; RX^PSO52API is a Pharmacy Re-Enginnering (PRE) API to get all
|
||||
; med data available.
|
||||
; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf
|
||||
; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS).
|
||||
; D PARY^C0CXPATH(MINXML)
|
||||
N MEDS,MAP
|
||||
K ^TMP($J,"CCDCCR") ; PLEASE DON'T KILL ALL OF ^TMP($J) HERE!!!!
|
||||
D RX^PSO52API(DFN,"CCDCCR")
|
||||
M MEDS=^TMP($J,"CCDCCR",DFN)
|
||||
; @(0) contains the number of meds or -1^NO DATA FOUND
|
||||
; If it is -1, we quit.
|
||||
I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT
|
||||
I DEBUG ZWR MEDS
|
||||
N RXIEN S RXIEN=0
|
||||
N MEDCOUNT S MEDCOUNT=0
|
||||
S MEDMAP=$NA(^TMP("C0CCCR",$J,"MEDMAP")) ; THIS IS THE VARIABLE MAP
|
||||
S MEDCOUNT=@MEDMAP@(0) ; ACCOUNT FOR MEDS ALREADY IN ARRAY
|
||||
F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="" D ; FOR EACH MEDICATION IN THE LIST
|
||||
. S MEDCOUNT=MEDCOUNT+1
|
||||
. I DEBUG W "RXIEN IS ",RXIEN,!
|
||||
. S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCOUNT))
|
||||
. ; K @MAP DO NOT KILL HERE, WAS CLEARED IN C0CMED
|
||||
. S @MEDMAP@(0)=@MEDMAP@(0)+1 ; INCREMENT TOTAL MEDS IN VAR ARRAY
|
||||
. I DEBUG W "MAP= ",MAP,!
|
||||
. N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
|
||||
. S @MAP@("MEDOBJECTID")="MED"_MEDCOUNT ; MEDCOUNT FOR ID
|
||||
. ; S @MAP@("MEDOBJECTID")="MED"_MED(.01) ;Rx Number
|
||||
. S @MAP@("MEDISSUEDATETXT")="Issue Date"
|
||||
. S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($P(MED(1),U))
|
||||
. S @MAP@("MEDLASTFILLDATETXT")="Last Fill Date"
|
||||
. S @MAP@("MEDLASTFILLDATE")=$$FMDTOUTC^C0CUTIL($P(MED(101),U))
|
||||
. S @MAP@("MEDRXNOTXT")="Prescription Number"
|
||||
. S @MAP@("MEDRXNO")=MED(.01)
|
||||
. S @MAP@("MEDTYPETEXT")="Medication"
|
||||
. S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses
|
||||
. S @MAP@("MEDSTATUSTEXT")=$P(MED(100),U,2)
|
||||
. S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$P(MED(4),U)
|
||||
. S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(6),U,2)
|
||||
. ; 12/30/08: I will be using RxNorm for coding...
|
||||
. ; 176.001 is the file for Concepts; 176.003 is the file for
|
||||
. ; sources (i.e. for RxNorm Version)
|
||||
. ;
|
||||
. ; We need the VUID first for the National Drug File entry first
|
||||
. ; We get the VUID of the drug, by looking up the VA Product entry
|
||||
. ; (file 50.68) using the call NDF^PSS50, returned in node 22.
|
||||
. ; Field 99.99 is the VUID.
|
||||
. ;
|
||||
. ; We use the VUID to look up the RxNorm in file 176.001; same idea.
|
||||
. ; Get IEN first using $$FIND1^DIC, then get the RxNorm number by
|
||||
. ; $$GET1^DIQ.
|
||||
. ;
|
||||
. ; I get the RxNorm name and version from the RxNorm Sources (file
|
||||
. ; 176.003), by searching for "RXNORM", then get the data.
|
||||
. N MEDIEN S MEDIEN=$P(MED(6),U)
|
||||
. D NDF^PSS50(MEDIEN,,,,,"NDF")
|
||||
. N NDFDATA M NDFDATA=^TMP($J,"NDF",MEDIEN)
|
||||
. N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
|
||||
. N VAPROD S VAPROD=$P(NDFDATA(22),U)
|
||||
. ;
|
||||
. ; NDFIEN is not necessarily defined; it won't be if the drug
|
||||
. ; is not matched to the national drug file (e.g. if the drug is
|
||||
. ; new on the market, compounded, or is a fake drug [blue pill].
|
||||
. ; To protect against failure, I will put an if/else block
|
||||
. ;
|
||||
. N VUID,RXNIEN,RXNORM,SRCIEN,RXNNAME,RXNVER
|
||||
. I NDFIEN,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet.
|
||||
. . S VUID=$$GET1^DIQ(50.68,VAPROD,99.99)
|
||||
. . S RXNIEN=$$FIND1^DIC(176.001,,,VUID,"VUID")
|
||||
. . S RXNORM=$$GET1^DIQ(176.001,RXNIEN,.01)
|
||||
. . S SRCIEN=$$FIND1^DIC(176.003,,"B","RXNORM")
|
||||
. . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6)
|
||||
. . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7)
|
||||
. ;
|
||||
. E S (RXNORM,RXNNAME,RXNVER)=""
|
||||
. ; End if/else block
|
||||
. S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM
|
||||
. S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME
|
||||
. S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER
|
||||
. ;
|
||||
. S @MAP@("MEDBRANDNAMETEXT")=MED(6.5)
|
||||
. D DOSE^PSS50(MEDIEN,,,,,"DOSE")
|
||||
. N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN)
|
||||
. S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901)
|
||||
. S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2)
|
||||
. ; Units, concentration, etc, come from another call
|
||||
. ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
|
||||
. ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
|
||||
. ; NDF Entry IEN, and VA Product IEN
|
||||
. ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
|
||||
. ; These have been collected above.
|
||||
. N CONCDATA
|
||||
. ; If a drug was not matched to NDF, then the NDFIEN is gonna be ""
|
||||
. ; and this will crash the call. So...
|
||||
. I NDFIEN="" S CONCDATA=""
|
||||
. E S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
|
||||
. S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
|
||||
. S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
|
||||
. S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
|
||||
. S @MAP@("MEDQUANTITYVALUE")=MED(7)
|
||||
. ; Oddly, there is no easy place to find the dispense unit.
|
||||
. ; It's not included in the original call, so we have to go to the drug file.
|
||||
. ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
|
||||
. ; Node 14.5 is the Dispense Unit
|
||||
. D DATA^PSS50(MEDIEN,,,,,"QTY")
|
||||
. N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN)
|
||||
. S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
|
||||
. ;
|
||||
. ; --- START OF DIRECTIONS ---
|
||||
. ; Sig data not in any API :-( Oh yes, you can get the whole thing, but...
|
||||
. ; we want the compoenents.
|
||||
. ; It's in node 6 of ^PSRX(IEN)
|
||||
. ; So, here we go again
|
||||
. ; ^PSRX(D0,6,D1,0)= (#.01) DOSAGE ORDERED [1F] ^ (#1) DISPENSE UNITS PER DOSE
|
||||
. ; ==>[2N] ^ (#2) UNITS [3P:50.607] ^ (#3) NOUN [4F] ^ (#4)
|
||||
. ; ==>DURATION [5F] ^ (#5) CONJUNCTION [6S] ^ (#6) ROUTE
|
||||
. ; ==>[7P:51.2] ^ (#7) SCHEDULE [8F] ^ (#8) VERB [9F] ^
|
||||
. ;
|
||||
. N DIRNUM S DIRNUM=0 ; Sigline number
|
||||
. S DIRCNT=0 ; COUNT OF MULTIPLE DIRECTIONS
|
||||
. F S DIRNUM=$O(^PSRX(RXIEN,6,DIRNUM)) Q:DIRNUM="" D
|
||||
. . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components.
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05.
|
||||
. . N SIGDATA S SIGDATA=^PSRX(RXIEN,6,DIRNUM,0)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$P(SIGDATA,U,9)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$P(SIGDATA,U,1)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$$GET1^DIQ(51.2,$P(SIGDATA,U,7),.01)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$P(SIGDATA,U,8)
|
||||
. . ; Invervals... again another call.
|
||||
. . ; In the wisdom of the original programmers, the schedule is a free text field
|
||||
. . ; However, it gets translated by a call to the administration schedule file
|
||||
. . ; to see if that schedule exists.
|
||||
. . ; That's the same thing I am going to do.
|
||||
. . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ).
|
||||
. . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO--
|
||||
. . ; I looked), PSSFT is the name, and list is the ^TMP name to store the data in.
|
||||
. . ; So...
|
||||
. . D AP^PSS51P1("PSJ",$P(SIGDATA,U,8),,,"SCHEDULE")
|
||||
. . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE")
|
||||
. . N INTERVAL
|
||||
. . I $P(SCHEDATA(0),U)=-1 S INTERVAL=""
|
||||
. . E D
|
||||
. . . N SUB S SUB=$O(SCHEDATA(0))
|
||||
. . . S INTERVAL=SCHEDATA(SUB,2)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute"
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$P(SIGDATA,U,5)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$P(SIGDATA,U,8)["PRN"
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM
|
||||
. . N DIRMOD S DIRMOD=$P(SIGDATA,U,6)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$S(DIRMOD="T":"THEN",DIRMOD="A":"AND",DIRMOD="X":"EXCEPT",1:"")
|
||||
. ;
|
||||
. ; --- END OF DIRECTIONS ---
|
||||
. ;
|
||||
. ; ^PSRX(22,"INS1",1,0)="FOR BLOOD PRESSURE"
|
||||
. S @MAP@("MEDPTINSTRUCTIONS")=$G(^PSRX(RXIEN,"INS1",1,0))
|
||||
. ; ^PSRX(22,"PRC",1,0)="Pharmacist: you must obey my command"
|
||||
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=$G(^PSRX(RXIEN,"PRC",1,0))
|
||||
. S @MAP@("MEDRFNO")=MED(9)
|
||||
. N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED"))
|
||||
. K @RESULT
|
||||
. D MAP^C0CXPATH(MINXML,MAP,RESULT)
|
||||
. ; D PARY^C0CXPATH(RESULT)
|
||||
. ; MAPPING DIRECTIONS
|
||||
. N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE
|
||||
. N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT
|
||||
. D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1)
|
||||
. D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions")
|
||||
. ; N MDZ1,MDZNA
|
||||
. I DIRCNT>0 D ; IF THERE ARE DIRCTIONS
|
||||
. . F MDZ1=1:1:DIRCNT D ; FOR EACH DIRECTION
|
||||
. . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",MDZ1))
|
||||
. . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2)
|
||||
. . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication")
|
||||
. D:MEDCOUNT=1 CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy
|
||||
. D:MEDCOUNT>1 INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML
|
||||
N MEDTMP,MEDI
|
||||
D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
|
||||
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
|
||||
. W "MEDICATION MISSING ",!
|
||||
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
|
||||
Q
|
||||
;
|
||||
C0CMED1 ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS ;01/10/09
|
||||
;;0.1;CCDCCR;;JUL 16,2008;
|
||||
;;Last modified Sat Jan 10 21:42:27 PST 2009
|
||||
; Copyright 2009 WorldVistA. Licensed under the terms of the GNU
|
||||
; General Public License See attached copy of the License.
|
||||
;
|
||||
; This program is free software; you can redistribute it and/or modify
|
||||
; it under the terms of the GNU General Public License as published by
|
||||
; the Free Software Foundation; either version 2 of the License, or
|
||||
; (at your option) any later version.
|
||||
;
|
||||
; This program is distributed in the hope that it will be useful,
|
||||
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
; GNU General Public License for more details.
|
||||
;
|
||||
; You should have received a copy of the GNU General Public License along
|
||||
; with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
W "NO ENTRY FROM TOP",!
|
||||
Q
|
||||
;
|
||||
EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
|
||||
;
|
||||
; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
|
||||
; INXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
|
||||
;
|
||||
; MEDS is return array from RPC.
|
||||
; MAP is a mapping variable map (store result) for each med
|
||||
; MED is holds each array element from MEDS(J), one medicine
|
||||
; MEDCOUNT is a counter passed by Reference.
|
||||
;
|
||||
; RX^PSO52API is a Pharmacy Re-Enginnering (PRE) API to get all
|
||||
; med data available.
|
||||
; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf
|
||||
; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS).
|
||||
; D PARY^C0CXPATH(MINXML)
|
||||
N MEDS,MAP
|
||||
K ^TMP($J,"CCDCCR") ; PLEASE DON'T KILL ALL OF ^TMP($J) HERE!!!!
|
||||
D RX^PSO52API(DFN,"CCDCCR")
|
||||
M MEDS=^TMP($J,"CCDCCR",DFN)
|
||||
; @(0) contains the number of meds or -1^NO DATA FOUND
|
||||
; If it is -1, we quit.
|
||||
I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT
|
||||
ZWRITE:$G(DEBUG) MEDS
|
||||
N RXIEN S RXIEN=0
|
||||
F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="" D ; FOR EACH MEDICATION IN THE LIST
|
||||
. S MEDCOUNT=MEDCOUNT+1
|
||||
. W:$G(DEBUG) "RXIEN IS ",RXIEN,!
|
||||
. S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCOUNT))
|
||||
. ; K @MAP DO NOT KILL HERE, WAS CLEARED IN C0CMED
|
||||
. W:$G(DEBUG) "MAP= ",MAP,!
|
||||
. N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
|
||||
. S @MAP@("MEDOBJECTID")="MED"_MEDCOUNT ; MEDCOUNT FOR ID
|
||||
. ; S @MAP@("MEDOBJECTID")="MED"_MED(.01) ;Rx Number
|
||||
. S @MAP@("MEDISSUEDATETXT")="Issue Date"
|
||||
. S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($P(MED(1),U))
|
||||
. S @MAP@("MEDLASTFILLDATETXT")="Last Fill Date"
|
||||
. S @MAP@("MEDLASTFILLDATE")=$$FMDTOUTC^C0CUTIL($P(MED(101),U))
|
||||
. S @MAP@("MEDRXNOTXT")="Prescription Number"
|
||||
. S @MAP@("MEDRXNO")=MED(.01)
|
||||
. S @MAP@("MEDTYPETEXT")="Medication"
|
||||
. S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses
|
||||
. S @MAP@("MEDSTATUSTEXT")=$P(MED(100),U,2)
|
||||
. S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$P(MED(4),U)
|
||||
. S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(6),U,2)
|
||||
. ; 12/30/08: I will be using RxNorm for coding...
|
||||
. ; 176.001 is the file for Concepts; 176.003 is the file for
|
||||
. ; sources (i.e. for RxNorm Version)
|
||||
. ;
|
||||
. ; We need the VUID first for the National Drug File entry first
|
||||
. ; We get the VUID of the drug, by looking up the VA Product entry
|
||||
. ; (file 50.68) using the call NDF^PSS50, returned in node 22.
|
||||
. ; Field 99.99 is the VUID.
|
||||
. ;
|
||||
. ; We use the VUID to look up the RxNorm in file 176.001; same idea.
|
||||
. ; Get IEN first using $$FIND1^DIC, then get the RxNorm number by
|
||||
. ; $$GET1^DIQ.
|
||||
. ;
|
||||
. ; I get the RxNorm name and version from the RxNorm Sources (file
|
||||
. ; 176.003), by searching for "RXNORM", then get the data.
|
||||
. N MEDIEN S MEDIEN=$P(MED(6),U)
|
||||
. D NDF^PSS50(MEDIEN,,,,,"NDF")
|
||||
. N NDFDATA M NDFDATA=^TMP($J,"NDF",MEDIEN)
|
||||
. N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
|
||||
. N VAPROD S VAPROD=$P(NDFDATA(22),U)
|
||||
. ;
|
||||
. ; NDFIEN is not necessarily defined; it won't be if the drug
|
||||
. ; is not matched to the national drug file (e.g. if the drug is
|
||||
. ; new on the market, compounded, or is a fake drug [blue pill].
|
||||
. ; To protect against failure, I will put an if/else block
|
||||
. ;
|
||||
. N VUID,RXNIEN,RXNORM,SRCIEN,RXNNAME,RXNVER
|
||||
. I NDFIEN,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet.
|
||||
. . S VUID=$$GET1^DIQ(50.68,VAPROD,99.99)
|
||||
. . S RXNIEN=$$FIND1^DIC(176.001,,,VUID,"VUID")
|
||||
. . S RXNORM=$$GET1^DIQ(176.001,RXNIEN,.01)
|
||||
. . S SRCIEN=$$FIND1^DIC(176.003,,"B","RXNORM")
|
||||
. . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6)
|
||||
. . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7)
|
||||
. ;
|
||||
. E S (RXNORM,RXNNAME,RXNVER)=""
|
||||
. ; End if/else block
|
||||
. S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM
|
||||
. S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME
|
||||
. S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER
|
||||
. ;
|
||||
. S @MAP@("MEDBRANDNAMETEXT")=MED(6.5)
|
||||
. D DOSE^PSS50(MEDIEN,,,,,"DOSE")
|
||||
. N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN)
|
||||
. S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901)
|
||||
. S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2)
|
||||
. ; Units, concentration, etc, come from another call
|
||||
. ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
|
||||
. ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
|
||||
. ; NDF Entry IEN, and VA Product IEN
|
||||
. ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
|
||||
. ; These have been collected above.
|
||||
. N CONCDATA
|
||||
. ; If a drug was not matched to NDF, then the NDFIEN is gonna be ""
|
||||
. ; and this will crash the call. So...
|
||||
. I NDFIEN="" S CONCDATA=""
|
||||
. E S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
|
||||
. S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
|
||||
. S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
|
||||
. S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
|
||||
. S @MAP@("MEDQUANTITYVALUE")=MED(7)
|
||||
. ; Oddly, there is no easy place to find the dispense unit.
|
||||
. ; It's not included in the original call, so we have to go to the drug file.
|
||||
. ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
|
||||
. ; Node 14.5 is the Dispense Unit
|
||||
. D DATA^PSS50(MEDIEN,,,,,"QTY")
|
||||
. N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN)
|
||||
. S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
|
||||
. ;
|
||||
. ; --- START OF DIRECTIONS ---
|
||||
. ; Sig data not in any API :-( Oh yes, you can get the whole thing, but...
|
||||
. ; we want the compoenents.
|
||||
. ; It's in node 6 of ^PSRX(IEN)
|
||||
. ; So, here we go again
|
||||
. ; ^PSRX(D0,6,D1,0)= (#.01) DOSAGE ORDERED [1F] ^ (#1) DISPENSE UNITS PER DOSE
|
||||
. ; ==>[2N] ^ (#2) UNITS [3P:50.607] ^ (#3) NOUN [4F] ^ (#4)
|
||||
. ; ==>DURATION [5F] ^ (#5) CONJUNCTION [6S] ^ (#6) ROUTE
|
||||
. ; ==>[7P:51.2] ^ (#7) SCHEDULE [8F] ^ (#8) VERB [9F] ^
|
||||
. ;
|
||||
. N DIRNUM S DIRNUM=0 ; Sigline number
|
||||
. S DIRCNT=0 ; COUNT OF MULTIPLE DIRECTIONS
|
||||
. F S DIRNUM=$O(^PSRX(RXIEN,6,DIRNUM)) Q:DIRNUM="" D
|
||||
. . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components.
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05.
|
||||
. . N SIGDATA S SIGDATA=^PSRX(RXIEN,6,DIRNUM,0)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$P(SIGDATA,U,9)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$P(SIGDATA,U,1)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$$GET1^DIQ(51.2,$P(SIGDATA,U,7),.01)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$P(SIGDATA,U,8)
|
||||
. . ; Invervals... again another call.
|
||||
. . ; In the wisdom of the original programmers, the schedule is a free text field
|
||||
. . ; However, it gets translated by a call to the administration schedule file
|
||||
. . ; to see if that schedule exists.
|
||||
. . ; That's the same thing I am going to do.
|
||||
. . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ).
|
||||
. . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO--
|
||||
. . ; I looked), PSSFT is the name, and list is the ^TMP name to store the data in.
|
||||
. . ; So...
|
||||
. . D AP^PSS51P1("PSJ",$P(SIGDATA,U,8),,,"SCHEDULE")
|
||||
. . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE")
|
||||
. . N INTERVAL
|
||||
. . I $P(SCHEDATA(0),U)=-1 S INTERVAL=""
|
||||
. . E D
|
||||
. . . N SUB S SUB=$O(SCHEDATA(0))
|
||||
. . . S INTERVAL=SCHEDATA(SUB,2)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute"
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$P(SIGDATA,U,5)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$P(SIGDATA,U,8)["PRN"
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM
|
||||
. . N DIRMOD S DIRMOD=$P(SIGDATA,U,6)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$S(DIRMOD="T":"THEN",DIRMOD="A":"AND",DIRMOD="X":"EXCEPT",1:"")
|
||||
. ;
|
||||
. ; --- END OF DIRECTIONS ---
|
||||
. ;
|
||||
. ; ^PSRX(22,"INS1",1,0)="FOR BLOOD PRESSURE"
|
||||
. S @MAP@("MEDPTINSTRUCTIONS")=$G(^PSRX(RXIEN,"INS1",1,0))
|
||||
. ; ^PSRX(22,"PRC",1,0)="Pharmacist: you must obey my command"
|
||||
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=$G(^PSRX(RXIEN,"PRC",1,0))
|
||||
. S @MAP@("MEDRFNO")=MED(9)
|
||||
. N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED"))
|
||||
. K @RESULT
|
||||
. D MAP^C0CXPATH(MINXML,MAP,RESULT)
|
||||
. ; MAPPING DIRECTIONS
|
||||
. N DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE
|
||||
. N DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT
|
||||
. D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1)
|
||||
. D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions")
|
||||
. ; N MDZ1,MDZNA
|
||||
. I DIRCNT>0 D ; IF THERE ARE DIRCTIONS
|
||||
. . F MDZ1=1:1:DIRCNT D ; FOR EACH DIRECTION
|
||||
. . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",MDZ1))
|
||||
. . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2)
|
||||
. . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication")
|
||||
. I MEDCOUNT=1 D CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy
|
||||
. E D INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER FIRST, INSERT INNER XML
|
||||
N MEDTMP,MEDI
|
||||
D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
|
||||
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
|
||||
. W "MEDICATION MISSING ",!
|
||||
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
|
||||
Q
|
||||
;
|
||||
|
|
537
p/C0CMED2.m
537
p/C0CMED2.m
|
@ -1,270 +1,267 @@
|
|||
C0CMED2 ; WV/CCDCCR/SMH - CCR/CCD Meds - Pending for Vista
|
||||
;;0.1;CCDCCR;;JUL 16,2008;
|
||||
;;Last Modified Sat Jan 10 21:41:14 PST 2009
|
||||
; Copyright 2008 WorldVistA. Licensed under the terms of the GNU
|
||||
; General Public License See attached copy of the License.
|
||||
;
|
||||
; This program is free software; you can redistribute it and/or modify
|
||||
; it under the terms of the GNU General Public License as published by
|
||||
; the Free Software Foundation; either version 2 of the License, or
|
||||
; (at your option) any later version.
|
||||
;
|
||||
; This program is distributed in the hope that it will be useful,
|
||||
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
; GNU General Public License for more details.
|
||||
;
|
||||
; You should have received a copy of the GNU General Public License along
|
||||
; with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
W "NO ENTRY FROM TOP",!
|
||||
Q
|
||||
;
|
||||
EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
|
||||
;
|
||||
; MINXML is the Input XML Template, passed by name
|
||||
; DFN is Patient IEN
|
||||
; OUTXML is the resultant XML.
|
||||
;
|
||||
; MEDS is return array from RPC.
|
||||
; MAP is a mapping variable map (store result) for each med
|
||||
; MED is holds each array element from MEDS, one medicine
|
||||
;
|
||||
; PEN^PSO5241 is a Pharmacy Re-Enginnering (PRE) API to get Pending
|
||||
; meds data available.
|
||||
; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf
|
||||
; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS).
|
||||
; File for pending meds is 52.41
|
||||
; Unfortuantely, API does not supply us with any useful info beyond
|
||||
; the IEN in 52.41, and the Med Name, and route.
|
||||
; So, most of the info is going to get pulled from 52.41.
|
||||
N MEDS,MAP
|
||||
K ^TMP($J,"CCDCCR") ; PLEASE DON'T KILL ALL OF ^TMP($J) HERE!!!!
|
||||
D PEN^PSO5241(DFN,"CCDCCR")
|
||||
M MEDS=^TMP($J,"CCDCCR",DFN)
|
||||
; @(0) contains the number of meds or -1^NO DATA FOUND
|
||||
; If it is -1, we quit.
|
||||
I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT
|
||||
I DEBUG ZWR MEDS
|
||||
N RXIEN S RXIEN=0
|
||||
N MEDCOUNT S MEDCOUNT=0
|
||||
N MEDFIRST S MEDFIRST=1 ; FLAG FOR FIRST MED IN THIS SECTION FOR MERGING
|
||||
S MEDMAP=$NA(^TMP("C0CCCR",$J,"MEDMAP")) ; THIS IS THE VARIABLE MAP
|
||||
S MEDCOUNT=@MEDMAP@(0) ; ACCOUNT FOR MEDS ALREADY IN ARRAY
|
||||
F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="B" D ; FOR EACH MEDICATION IN THE LIST
|
||||
. I $$GET1^DIQ(52.41,RXIEN,2,"I")="RF" QUIT ; Dont' want refill request as a "pending" order
|
||||
. S MEDCOUNT=MEDCOUNT+1
|
||||
. I DEBUG W "RXIEN IS ",RXIEN,!
|
||||
. S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCOUNT))
|
||||
. ; K @MAP DON'T KILL MAP HERE, IT IS DONE IN C0CMED
|
||||
. S @MEDMAP@(0)=@MEDMAP@(0)+1 ; INCREMENT TOTAL MEDS IN VAR ARRAY
|
||||
. I DEBUG W "MAP= ",MAP,!
|
||||
. N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
|
||||
. S @MAP@("MEDOBJECTID")="MED_PENDING"_MEDCOUNT ; MEDCOUNT FOR ID
|
||||
. ; S @MAP@("MEDOBJECTID")="MED_PENDING"_MED(.01) ;Pending IEN
|
||||
. S @MAP@("MEDISSUEDATETXT")="Issue Date"
|
||||
. ; Field 6 is "Effective date", and we pull it in timson format w/ I
|
||||
. S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($$GET1^DIQ(52.41,RXIEN,6,"I"),"DT")
|
||||
. ; Med never filled; next 4 fields are not applicable.
|
||||
. S @MAP@("MEDLASTFILLDATETXT")=""
|
||||
. S @MAP@("MEDLASTFILLDATE")=""
|
||||
. S @MAP@("MEDRXNOTXT")=""
|
||||
. S @MAP@("MEDRXNO")=""
|
||||
. S @MAP@("MEDTYPETEXT")="Medication"
|
||||
. S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses
|
||||
. S @MAP@("MEDSTATUSTEXT")="On Hold" ; nearest status for pending meds
|
||||
. S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52.41,RXIEN,5,"I")
|
||||
. S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(11),U,2)
|
||||
. ; NDC not supplied in API, but is rather trivial to obtain
|
||||
. ; MED(11) piece 1 has the IEN of the drug (file 50)
|
||||
. ; IEN is field 31 in the drug file.
|
||||
. ;
|
||||
. ; MEDIEN (node 11 in the returned output) might not necessarily be defined
|
||||
. ; It is not defined when a dose in not chosen in CPRS. There is a long
|
||||
. ; series of fields that depend on it. We will use If and Else to deal
|
||||
. ; with that
|
||||
. N MEDIEN S MEDIEN=$P(MED(11),U)
|
||||
. I +MEDIEN>0 D ; start of if/else block
|
||||
. . ; 12/30/08: I will be using RxNorm for coding...
|
||||
. . ; 176.001 is the file for Concepts; 176.003 is the file for
|
||||
. . ; sources (i.e. for RxNorm Version)
|
||||
. . ;
|
||||
. . ; We need the VUID first for the National Drug File entry first
|
||||
. . ; We get the VUID of the drug, by looking up the VA Product entry
|
||||
. . ; (file 50.68) using the call NDF^PSS50, returned in node 22.
|
||||
. . ; Field 99.99 is the VUID.
|
||||
. . ;
|
||||
. . ; We use the VUID to look up the RxNorm in file 176.001; same idea.
|
||||
. . ; Get IEN first using $$FIND1^DIC, then get the RxNorm number by
|
||||
. . ; $$GET1^DIQ.
|
||||
. . ;
|
||||
. . ; I get the RxNorm name and version from the RxNorm Sources (file
|
||||
. . ; 176.003), by searching for "RXNORM", then get the data.
|
||||
. . D NDF^PSS50(MEDIEN,,,,,"NDF")
|
||||
. . N NDFDATA M NDFDATA=^TMP($J,"NDF",MEDIEN)
|
||||
. . N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
|
||||
. . N VAPROD S VAPROD=$P(NDFDATA(22),U)
|
||||
. . ;
|
||||
. . ; NDFIEN is not necessarily defined; it won't be if the drug
|
||||
. . ; is not matched to the national drug file (e.g. if the drug is
|
||||
. . ; new on the market, compounded, or is a fake drug [blue pill].
|
||||
. . ; To protect against failure, I will put an if/else block
|
||||
. . N VUID,RXNIEN,RXNORM,SRCIEN,RXNNAME,RXNVER
|
||||
. . I NDFIEN,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet.
|
||||
. . . S VUID=$$GET1^DIQ(50.68,VAPROD,99.99)
|
||||
. . . S RXNIEN=$$FIND1^DIC(176.001,,,VUID,"VUID")
|
||||
. . . S RXNORM=$$GET1^DIQ(176.001,RXNIEN,.01)
|
||||
. . . S SRCIEN=$$FIND1^DIC(176.003,,"B","RXNORM")
|
||||
. . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6)
|
||||
. . . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7)
|
||||
. . ;
|
||||
. . E S (RXNORM,RXNNAME,RXNVER)=""
|
||||
. . ; End if/else block
|
||||
. . S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM
|
||||
. . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME
|
||||
. . S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER
|
||||
. . ;
|
||||
. . S @MAP@("MEDBRANDNAMETEXT")=""
|
||||
. . D DOSE^PSS50(MEDIEN,,,,,"DOSE")
|
||||
. . N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN)
|
||||
. . S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901)
|
||||
. . S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2)
|
||||
. . ; Units, concentration, etc, come from another call
|
||||
. . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
|
||||
. . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
|
||||
. . ; NDF Entry IEN, and VA Product Name
|
||||
. . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
|
||||
. . ; Documented in the same manual; executed above.
|
||||
. . N CONCDATA
|
||||
. . ; If a drug was not matched to NDF, then the NDFIEN is gonna be ""
|
||||
. . ; and this will crash the call. So...
|
||||
. . I NDFIEN="" S CONCDATA=""
|
||||
. . E S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
|
||||
. . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
|
||||
. . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
|
||||
. . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
|
||||
. . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52.41,RXIEN,12)
|
||||
. . ; Oddly, there is no easy place to find the dispense unit.
|
||||
. . ; It's not included in the original call, so we have to go to the drug file.
|
||||
. . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
|
||||
. . ; Node 14.5 is the Dispense Unit
|
||||
. . D DATA^PSS50(MEDIEN,,,,,"QTY")
|
||||
. . N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN)
|
||||
. . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
|
||||
. E D
|
||||
. . S @MAP@("MEDPRODUCTNAMECODEVALUE")=""
|
||||
. . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=""
|
||||
. . S @MAP@("MEDPRODUCTNAMECODEVERSION")=""
|
||||
. . S @MAP@("MEDBRANDNAMETEXT")=""
|
||||
. . S @MAP@("MEDSTRENGTHVALUE")=""
|
||||
. . S @MAP@("MEDSTRENGTHUNIT")=""
|
||||
. . S @MAP@("MEDFORMTEXT")=""
|
||||
. . S @MAP@("MEDCONCVALUE")=""
|
||||
. . S @MAP@("MEDCONCUNIT")=""
|
||||
. . S @MAP@("MEDSIZETEXT")=""
|
||||
. . S @MAP@("MEDQUANTITYVALUE")=""
|
||||
. . S @MAP@("MEDQUANTITYUNIT")=""
|
||||
. ; end of if/else block
|
||||
. ;
|
||||
. ; --- START OF DIRECTIONS ---
|
||||
. ; Sig data is not in any API. We obtain it using the IEN from
|
||||
. ; the PEN API to file 52.41. It's in field 3, which is a multiple.
|
||||
. ; I will be using FM call GETS^DIQ(FILE,IENS,FIELD,FLAGS,TARGET_ROOT)
|
||||
. K FMSIG ; it's passed via the symbol table, so remove any leftovers from last call
|
||||
. D GETS^DIQ(52.41,RXIEN,"3*",,"FMSIG")
|
||||
. N FMSIGNUM S FMSIGNUM=0 ; Sigline number in fileman.
|
||||
. ; FMSIGNUM gets outputted as "IEN,RXIEN,".
|
||||
. ; DIRNUM will be first piece for IEN.
|
||||
. ; DIRNUM is the proper Sigline numer.
|
||||
. ; SIGDATA is the simplfied array. Subscripts are really field numbers
|
||||
. ; in subfile 52.413.
|
||||
. N DIRCNT S DIRCNT=0 ; COUNT OF DIRECTIONS
|
||||
. F S FMSIGNUM=$O(FMSIG(52.413,FMSIGNUM)) Q:FMSIGNUM="" D
|
||||
. . N DIRNUM S DIRNUM=$P(FMSIGNUM,",")
|
||||
. . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT
|
||||
. . N SIGDATA M SIGDATA=FMSIG(52.413,FMSIGNUM)
|
||||
. . ; If this is an order for a refill; it's not really a new order; move on to next
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components.
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05.
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=SIGDATA(13)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=SIGDATA(8)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=SIGDATA(10)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=SIGDATA(1)
|
||||
. . ; Invervals... again another call.
|
||||
. . ; The schedule is a free text field
|
||||
. . ; However, it gets translated by a call to the administration
|
||||
. . ; schedule file to see if that schedule exists.
|
||||
. . ; That's the same thing I am going to do.
|
||||
. . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ).
|
||||
. . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO--
|
||||
. . ; I looked), PSSFT is the name,
|
||||
. . ; and list is the ^TMP name to store the data in.
|
||||
. . ; Also, freqency may have "PRN" in it, so strip that out
|
||||
. . N FREQ S FREQ=SIGDATA(1)
|
||||
. . I FREQ["PRN" S FREQ=$E(FREQ,1,$F(FREQ,"PRN")-5) ; 5 for $L("PRN") + 1 + sp
|
||||
. . D AP^PSS51P1("PSJ",FREQ,,,"SCHEDULE")
|
||||
. . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE")
|
||||
. . N INTERVAL
|
||||
. . I $P(SCHEDATA(0),U)=-1 S INTERVAL=""
|
||||
. . E D
|
||||
. . . N SUB S SUB=$O(SCHEDATA(0))
|
||||
. . . S INTERVAL=SCHEDATA(SUB,2)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute"
|
||||
. . ; Duration comes as M2,H2,D2,W2,L2 for 2 minutes,hours,days,weeks,months
|
||||
. . N DUR S DUR=SIGDATA(2)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$E(DUR,2,$L(DUR))
|
||||
. . N DURUNIT S DURUNIT=$E(DUR)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"")
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=SIGDATA(1)["PRN"
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" ; Vista doesn't have that field
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=SIGDATA(6)
|
||||
. ;
|
||||
. ; --- END OF DIRECTIONS ---
|
||||
. ;
|
||||
. ; S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
|
||||
. S @MAP@("MEDPTINSTRUCTIONS")=$G(^PSRX(RXIEN,"PI",1,0)) ;GPL
|
||||
. ; W @MAP@("MEDPTINSTRUCTIONS"),!
|
||||
. ; S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
|
||||
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=$G(^PSRX(RXIEN,"SIG1",1,0)) ;GPL
|
||||
. ; W @MAP@("MEDFULLFILLMENTINSTRUCTIONS"),!
|
||||
. S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13)
|
||||
. N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED"))
|
||||
. K @RESULT
|
||||
. D MAP^C0CXPATH(MINXML,MAP,RESULT)
|
||||
. ; D PARY^C0CXPATH(RESULT)
|
||||
. ; MAPPING DIRECTIONS
|
||||
. N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE
|
||||
. N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT
|
||||
. D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1)
|
||||
. D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions")
|
||||
. ; N MDZ1,MDZNA
|
||||
. I DIRCNT>0 D ; IF THERE ARE DIRCTIONS
|
||||
. . F MDZ1=1:1:DIRCNT D ; FOR EACH DIRECTION
|
||||
. . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",MDZ1))
|
||||
. . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2)
|
||||
. . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication")
|
||||
. I MEDFIRST D ;
|
||||
. . S MEDFIRST=0 ; RESET FIRST FLAG
|
||||
. . D CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy
|
||||
. D:'MEDFIRST INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER FIRST, INSERT INNER XML
|
||||
N MEDTMP,MEDI
|
||||
D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
|
||||
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
|
||||
. W "MEDICATION MISSING ",!
|
||||
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
|
||||
Q
|
||||
;
|
||||
C0CMED2 ; WV/CCDCCR/SMH - CCR/CCD Meds - Pending for Vista
|
||||
;;0.1;CCDCCR;;JUL 16,2008;
|
||||
;;Last Modified Sat Jan 10 21:41:14 PST 2009
|
||||
; Copyright 2008 WorldVistA. Licensed under the terms of the GNU
|
||||
; General Public License See attached copy of the License.
|
||||
;
|
||||
; This program is free software; you can redistribute it and/or modify
|
||||
; it under the terms of the GNU General Public License as published by
|
||||
; the Free Software Foundation; either version 2 of the License, or
|
||||
; (at your option) any later version.
|
||||
;
|
||||
; This program is distributed in the hope that it will be useful,
|
||||
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
; GNU General Public License for more details.
|
||||
;
|
||||
; You should have received a copy of the GNU General Public License along
|
||||
; with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
W "NO ENTRY FROM TOP",!
|
||||
Q
|
||||
;
|
||||
EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
|
||||
;
|
||||
; MINXML is the Input XML Template, passed by name
|
||||
; DFN is Patient IEN (by Value)
|
||||
; OUTXML is the resultant XML (by Name)
|
||||
; MEDCOUNT is the current count of extracted meds, passed by Reference
|
||||
;
|
||||
; MEDS is return array from RPC.
|
||||
; MAP is a mapping variable map (store result) for each med
|
||||
; MED is holds each array element from MEDS, one medicine
|
||||
;
|
||||
; PEN^PSO5241 is a Pharmacy Re-Enginnering (PRE) API to get Pending
|
||||
; meds data available.
|
||||
; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf
|
||||
; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS).
|
||||
; File for pending meds is 52.41
|
||||
; Unfortuantely, API does not supply us with any useful info beyond
|
||||
; the IEN in 52.41, and the Med Name, and route.
|
||||
; So, most of the info is going to get pulled from 52.41.
|
||||
N MEDS,MAP
|
||||
K ^TMP($J,"CCDCCR") ; PLEASE DON'T KILL ALL OF ^TMP($J) HERE!!!!
|
||||
D PEN^PSO5241(DFN,"CCDCCR")
|
||||
M MEDS=^TMP($J,"CCDCCR",DFN)
|
||||
; @(0) contains the number of meds or -1^NO DATA FOUND
|
||||
; If it is -1, we quit.
|
||||
I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT
|
||||
ZWRITE:$G(DEBUG) MEDS
|
||||
N RXIEN S RXIEN=0
|
||||
N MEDFIRST S MEDFIRST=1 ; FLAG FOR FIRST MED IN THIS SECTION FOR MERGING
|
||||
F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="B" D ; FOR EACH MEDICATION IN THE LIST
|
||||
. I $$GET1^DIQ(52.41,RXIEN,2,"I")="RF" QUIT ; Dont' want refill request as a "pending" order
|
||||
. S MEDCOUNT=MEDCOUNT+1
|
||||
. I DEBUG W "RXIEN IS ",RXIEN,!
|
||||
. S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCOUNT))
|
||||
. ; K @MAP DON'T KILL MAP HERE, IT IS DONE IN C0CMED
|
||||
. I DEBUG W "MAP= ",MAP,!
|
||||
. N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
|
||||
. S @MAP@("MEDOBJECTID")="MED_PENDING"_MEDCOUNT ; MEDCOUNT FOR ID
|
||||
. ; S @MAP@("MEDOBJECTID")="MED_PENDING"_MED(.01) ;Pending IEN
|
||||
. S @MAP@("MEDISSUEDATETXT")="Issue Date"
|
||||
. ; Field 6 is "Effective date", and we pull it in timson format w/ I
|
||||
. S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($$GET1^DIQ(52.41,RXIEN,6,"I"),"DT")
|
||||
. ; Med never filled; next 4 fields are not applicable.
|
||||
. S @MAP@("MEDLASTFILLDATETXT")=""
|
||||
. S @MAP@("MEDLASTFILLDATE")=""
|
||||
. S @MAP@("MEDRXNOTXT")=""
|
||||
. S @MAP@("MEDRXNO")=""
|
||||
. S @MAP@("MEDTYPETEXT")="Medication"
|
||||
. S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses
|
||||
. S @MAP@("MEDSTATUSTEXT")="On Hold" ; nearest status for pending meds
|
||||
. S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52.41,RXIEN,5,"I")
|
||||
. S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(11),U,2)
|
||||
. ; NDC not supplied in API, but is rather trivial to obtain
|
||||
. ; MED(11) piece 1 has the IEN of the drug (file 50)
|
||||
. ; IEN is field 31 in the drug file.
|
||||
. ;
|
||||
. ; MEDIEN (node 11 in the returned output) might not necessarily be defined
|
||||
. ; It is not defined when a dose in not chosen in CPRS. There is a long
|
||||
. ; series of fields that depend on it. We will use If and Else to deal
|
||||
. ; with that
|
||||
. N MEDIEN S MEDIEN=$P(MED(11),U)
|
||||
. I +MEDIEN>0 D ; start of if/else block
|
||||
. . ; 12/30/08: I will be using RxNorm for coding...
|
||||
. . ; 176.001 is the file for Concepts; 176.003 is the file for
|
||||
. . ; sources (i.e. for RxNorm Version)
|
||||
. . ;
|
||||
. . ; We need the VUID first for the National Drug File entry first
|
||||
. . ; We get the VUID of the drug, by looking up the VA Product entry
|
||||
. . ; (file 50.68) using the call NDF^PSS50, returned in node 22.
|
||||
. . ; Field 99.99 is the VUID.
|
||||
. . ;
|
||||
. . ; We use the VUID to look up the RxNorm in file 176.001; same idea.
|
||||
. . ; Get IEN first using $$FIND1^DIC, then get the RxNorm number by
|
||||
. . ; $$GET1^DIQ.
|
||||
. . ;
|
||||
. . ; I get the RxNorm name and version from the RxNorm Sources (file
|
||||
. . ; 176.003), by searching for "RXNORM", then get the data.
|
||||
. . D NDF^PSS50(MEDIEN,,,,,"NDF")
|
||||
. . N NDFDATA M NDFDATA=^TMP($J,"NDF",MEDIEN)
|
||||
. . N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
|
||||
. . N VAPROD S VAPROD=$P(NDFDATA(22),U)
|
||||
. . ;
|
||||
. . ; NDFIEN is not necessarily defined; it won't be if the drug
|
||||
. . ; is not matched to the national drug file (e.g. if the drug is
|
||||
. . ; new on the market, compounded, or is a fake drug [blue pill].
|
||||
. . ; To protect against failure, I will put an if/else block
|
||||
. . N VUID,RXNIEN,RXNORM,SRCIEN,RXNNAME,RXNVER
|
||||
. . I NDFIEN,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet.
|
||||
. . . S VUID=$$GET1^DIQ(50.68,VAPROD,99.99)
|
||||
. . . S RXNIEN=$$FIND1^DIC(176.001,,,VUID,"VUID")
|
||||
. . . S RXNORM=$$GET1^DIQ(176.001,RXNIEN,.01)
|
||||
. . . S SRCIEN=$$FIND1^DIC(176.003,,"B","RXNORM")
|
||||
. . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6)
|
||||
. . . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7)
|
||||
. . ;
|
||||
. . E S (RXNORM,RXNNAME,RXNVER)=""
|
||||
. . ; End if/else block
|
||||
. . S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM
|
||||
. . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME
|
||||
. . S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER
|
||||
. . ;
|
||||
. . S @MAP@("MEDBRANDNAMETEXT")=""
|
||||
. . D DOSE^PSS50(MEDIEN,,,,,"DOSE")
|
||||
. . N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN)
|
||||
. . S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901)
|
||||
. . S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2)
|
||||
. . ; Units, concentration, etc, come from another call
|
||||
. . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
|
||||
. . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
|
||||
. . ; NDF Entry IEN, and VA Product Name
|
||||
. . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
|
||||
. . ; Documented in the same manual; executed above.
|
||||
. . N CONCDATA
|
||||
. . ; If a drug was not matched to NDF, then the NDFIEN is gonna be ""
|
||||
. . ; and this will crash the call. So...
|
||||
. . I NDFIEN="" S CONCDATA=""
|
||||
. . E S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
|
||||
. . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
|
||||
. . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
|
||||
. . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
|
||||
. . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52.41,RXIEN,12)
|
||||
. . ; Oddly, there is no easy place to find the dispense unit.
|
||||
. . ; It's not included in the original call, so we have to go to the drug file.
|
||||
. . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
|
||||
. . ; Node 14.5 is the Dispense Unit
|
||||
. . D DATA^PSS50(MEDIEN,,,,,"QTY")
|
||||
. . N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN)
|
||||
. . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
|
||||
. E D
|
||||
. . S @MAP@("MEDPRODUCTNAMECODEVALUE")=""
|
||||
. . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=""
|
||||
. . S @MAP@("MEDPRODUCTNAMECODEVERSION")=""
|
||||
. . S @MAP@("MEDBRANDNAMETEXT")=""
|
||||
. . S @MAP@("MEDSTRENGTHVALUE")=""
|
||||
. . S @MAP@("MEDSTRENGTHUNIT")=""
|
||||
. . S @MAP@("MEDFORMTEXT")=""
|
||||
. . S @MAP@("MEDCONCVALUE")=""
|
||||
. . S @MAP@("MEDCONCUNIT")=""
|
||||
. . S @MAP@("MEDSIZETEXT")=""
|
||||
. . S @MAP@("MEDQUANTITYVALUE")=""
|
||||
. . S @MAP@("MEDQUANTITYUNIT")=""
|
||||
. ; end of if/else block
|
||||
. ;
|
||||
. ; --- START OF DIRECTIONS ---
|
||||
. ; Sig data is not in any API. We obtain it using the IEN from
|
||||
. ; the PEN API to file 52.41. It's in field 3, which is a multiple.
|
||||
. ; I will be using FM call GETS^DIQ(FILE,IENS,FIELD,FLAGS,TARGET_ROOT)
|
||||
. K FMSIG ; it's passed via the symbol table, so remove any leftovers from last call
|
||||
. D GETS^DIQ(52.41,RXIEN,"3*",,"FMSIG")
|
||||
. N FMSIGNUM S FMSIGNUM=0 ; Sigline number in fileman.
|
||||
. ; FMSIGNUM gets outputted as "IEN,RXIEN,".
|
||||
. ; DIRNUM will be first piece for IEN.
|
||||
. ; DIRNUM is the proper Sigline numer.
|
||||
. ; SIGDATA is the simplfied array. Subscripts are really field numbers
|
||||
. ; in subfile 52.413.
|
||||
. N DIRCNT S DIRCNT=0 ; COUNT OF DIRECTIONS
|
||||
. F S FMSIGNUM=$O(FMSIG(52.413,FMSIGNUM)) Q:FMSIGNUM="" D
|
||||
. . N DIRNUM S DIRNUM=$P(FMSIGNUM,",")
|
||||
. . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT
|
||||
. . N SIGDATA M SIGDATA=FMSIG(52.413,FMSIGNUM)
|
||||
. . ; If this is an order for a refill; it's not really a new order; move on to next
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components.
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05.
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=SIGDATA(13)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=SIGDATA(8)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=SIGDATA(10)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=SIGDATA(1)
|
||||
. . ; Invervals... again another call.
|
||||
. . ; The schedule is a free text field
|
||||
. . ; However, it gets translated by a call to the administration
|
||||
. . ; schedule file to see if that schedule exists.
|
||||
. . ; That's the same thing I am going to do.
|
||||
. . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ).
|
||||
. . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO--
|
||||
. . ; I looked), PSSFT is the name,
|
||||
. . ; and list is the ^TMP name to store the data in.
|
||||
. . ; Also, freqency may have "PRN" in it, so strip that out
|
||||
. . N FREQ S FREQ=SIGDATA(1)
|
||||
. . I FREQ["PRN" S FREQ=$E(FREQ,1,$F(FREQ,"PRN")-5) ; 5 for $L("PRN") + 1 + sp
|
||||
. . D AP^PSS51P1("PSJ",FREQ,,,"SCHEDULE")
|
||||
. . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE")
|
||||
. . N INTERVAL
|
||||
. . I $P(SCHEDATA(0),U)=-1 S INTERVAL=""
|
||||
. . E D
|
||||
. . . N SUB S SUB=$O(SCHEDATA(0))
|
||||
. . . S INTERVAL=SCHEDATA(SUB,2)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute"
|
||||
. . ; Duration comes as M2,H2,D2,W2,L2 for 2 minutes,hours,days,weeks,months
|
||||
. . N DUR S DUR=SIGDATA(2)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$E(DUR,2,$L(DUR))
|
||||
. . N DURUNIT S DURUNIT=$E(DUR)
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"")
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=SIGDATA(1)["PRN"
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")=""
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" ; Vista doesn't have that field
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM
|
||||
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=SIGDATA(6)
|
||||
. ;
|
||||
. ; --- END OF DIRECTIONS ---
|
||||
. ;
|
||||
. ; S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
|
||||
. S @MAP@("MEDPTINSTRUCTIONS")=$G(^PSRX(RXIEN,"PI",1,0)) ;GPL
|
||||
. ; W @MAP@("MEDPTINSTRUCTIONS"),!
|
||||
. ; S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
|
||||
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=$G(^PSRX(RXIEN,"SIG1",1,0)) ;GPL
|
||||
. ; W @MAP@("MEDFULLFILLMENTINSTRUCTIONS"),!
|
||||
. S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13)
|
||||
. N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED"))
|
||||
. K @RESULT
|
||||
. D MAP^C0CXPATH(MINXML,MAP,RESULT)
|
||||
. ; D PARY^C0CXPATH(RESULT)
|
||||
. ; MAPPING DIRECTIONS
|
||||
. N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE
|
||||
. N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT
|
||||
. D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1)
|
||||
. D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions")
|
||||
. ; N MDZ1,MDZNA
|
||||
. I DIRCNT>0 D ; IF THERE ARE DIRCTIONS
|
||||
. . F MDZ1=1:1:DIRCNT D ; FOR EACH DIRECTION
|
||||
. . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",MDZ1))
|
||||
. . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2)
|
||||
. . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication")
|
||||
. I MEDFIRST D ;
|
||||
. . S MEDFIRST=0 ; RESET FIRST FLAG
|
||||
. . D CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy
|
||||
. D:'MEDFIRST INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER FIRST, INSERT INNER XML
|
||||
N MEDTMP,MEDI
|
||||
D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
|
||||
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
|
||||
. W "Pending Medication MISSING ",!
|
||||
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
|
||||
Q
|
||||
;
|
||||
|
|
14
p/C0CMED3.m
14
p/C0CMED3.m
|
@ -21,11 +21,12 @@ C0CMED3 ; WV/CCDCCR/SMH - Meds: Non-VA/Outside Meds for Vista
|
|||
W "NO ENTRY FROM TOP",!
|
||||
Q
|
||||
;
|
||||
EXTRACT(MINXML,DFN,OUTXML) ; Extract medications into provided xml template
|
||||
EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; Extract medications into provided xml template
|
||||
;
|
||||
; MINXML is the Input XML Template, passed by name
|
||||
; DFN is Patient IEN
|
||||
; OUTXML is the resultant XML.
|
||||
; MINXML is the Input XML Template, (passed by name)
|
||||
; DFN is Patient IEN (passed by value)
|
||||
; OUTXML is the resultant XML (passed by name)
|
||||
; MEDCOUNT is the number of Meds extracted so far (passed by reference)
|
||||
;
|
||||
; MEDS is return array from RPC.
|
||||
; MAP is a mapping variable map (store result) for each med
|
||||
|
@ -38,7 +39,7 @@ EXTRACT(MINXML,DFN,OUTXML) ; Extract medications into provided xml template
|
|||
;
|
||||
N MEDS,MAP
|
||||
K ^TMP($J,"CCDCCR") ; PLEASE DON'T KILL ALL OF ^TMP($J) HERE!!!!
|
||||
K NVA
|
||||
N NVA
|
||||
D GETS^DIQ(55,DFN,"52.2*","IE","NVA") ; Output in NVA in FDA array format.
|
||||
; If NVA does not exist, then patient has no non-VA meds
|
||||
I $D(NVA)=0 S @OUTXML@(0)=0 QUIT
|
||||
|
@ -49,15 +50,12 @@ EXTRACT(MINXML,DFN,OUTXML) ; Extract medications into provided xml template
|
|||
;
|
||||
I DEBUG ZWR MEDS
|
||||
N FDAIEN S FDAIEN=0 ; For use in $Order in the MEDS array.
|
||||
S MEDMAP=$NA(^TMP("C0CCCR",$J,"MEDMAP"))
|
||||
N MEDCOUNT S MEDCOUNT=@MEDMAP@(0) ; We already have meds in the array
|
||||
N MEDFIRST S MEDFIRST=1 ; FLAG FOR FIRST MED PROCESSED HERE
|
||||
F S FDAIEN=$O(MEDS(FDAIEN)) Q:FDAIEN="" D ; FOR EACH MEDICATION IN THE LIST
|
||||
. N MED M MED=MEDS(FDAIEN)
|
||||
. I MED(5,"I")!MED(6,"I") QUIT ; If disconinued, we don't want to pull it.
|
||||
. S MEDCOUNT=MEDCOUNT+1
|
||||
. S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCOUNT))
|
||||
. S @MEDMAP@(0)=@MEDMAP@(0)+1 ; INCREMENT TOTAL MEDS IN VAR ARRAY
|
||||
. N RXIEN S RXIEN=$P(FDAIEN,",") ; First piece of FDAIEN is the number of the med for this patient
|
||||
. I DEBUG W "RXIEN IS ",RXIEN,!
|
||||
. I DEBUG W "MAP= ",MAP,!
|
||||
|
|
262
p/C0CUTIL.m
262
p/C0CUTIL.m
|
@ -1,130 +1,132 @@
|
|||
C0CUTIL ;WV/C0C/SMH - Various Utilites for generating the CCR/CCD;06/15/08
|
||||
;;0.1;C0C;;Jun 15, 2008;
|
||||
;Copyright 2008-2009 Sam Habiel & George Lilly.
|
||||
;Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
W "No Entry at Top!"
|
||||
Q
|
||||
;
|
||||
FMDTOUTC(DATE,FORMAT) ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrinsic
|
||||
; FORMAT is Format of Date. Can be either D (Day) or DT (Date and Time)
|
||||
; If not passed, or passed incorrectly, it's assumed that it is D.
|
||||
; FM Date format is "YYYMMDD.HHMMSS" HHMMSS may not be supplied.
|
||||
; UTC date is formatted as follows: YYYY-MM-DDThh:mm:ss_offsetfromUTC
|
||||
; UTC, Year, Month, Day, Hours, Minutes, Seconds, Time offset (obtained from Mailman Site Parameters)
|
||||
N UTC,Y,M,D,H,MM,S,OFF
|
||||
S Y=1700+$E(DATE,1,3)
|
||||
S M=$E(DATE,4,5)
|
||||
S D=$E(DATE,6,7)
|
||||
S H=$E(DATE,9,10)
|
||||
I $L(H)=1 S H="0"_H
|
||||
S MM=$E(DATE,11,12)
|
||||
I $L(MM)=1 S MM="0"_MM
|
||||
S S=$E(DATE,13,14)
|
||||
I $L(S)=1 S S="0"_S
|
||||
S OFF=$$TZ^XLFDT ; See Kernel Manual for documentation.
|
||||
S OFFS=$E(OFF,1,1)
|
||||
S OFF0=$TR(OFF,"+-")
|
||||
S OFF1=$E(OFF0+10000,2,3)
|
||||
S OFF2=$E(OFF0+10000,4,5)
|
||||
S OFF=OFFS_OFF1_":"_OFF2
|
||||
;S OFF2=$E(OFF,1,2) ;
|
||||
;S OFF2=$E(100+OFF2,2,3) ; GPL 11/08 CHANGED TO -05:00 FORMAT
|
||||
;S OFF3=$E(OFF,3,4) ;MINUTES
|
||||
;S OFF=$S(OFF2="":"00",0:"00",1:OFF2)_"."_$S(OFF3="":"00",1:OFF3)
|
||||
; If H, MM and S are empty, it means that the FM date didn't supply the time.
|
||||
; In this case, set H, MM and S to "00"
|
||||
; S:('$L(H)&'$L(MM)&'$L(S)) (H,MM,S)="00" ; IF ONLY SOME ARE MISSING?
|
||||
S:'$L(H) H="00"
|
||||
S:'$L(MM) MM="00"
|
||||
S:'$L(S) S="00"
|
||||
S UTC=Y_"-"_M_"-"_D_"T"_H_":"_MM_$S(S="":":00",1:":"_S)_OFF ; Skip's code to fix hanging colon if no seconds
|
||||
I $L($G(FORMAT)),FORMAT="DT" Q UTC ; Date with time.
|
||||
E Q $P(UTC,"T")
|
||||
;
|
||||
SORTDT(V1,V2,ORDR) ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT
|
||||
; AS EXTRINSIC ORDR IS 1 OR -1 FOR FORWARD OR REVERSE
|
||||
; DATE AND TIME ORDER. DEFAULT IS FORWARD
|
||||
; V2 IS AN ARRAY OF DATES IN FILEMAN FORMAT
|
||||
; V1 IS RETURNS INDIRECT INDEXES OF V2 IN REVERSE DATE ORDER
|
||||
; SO V2(V1(X)) WILL RETURN THE DATES IN DATE/TIME ORDER
|
||||
; THE COUNT OF THE DATES IS RETURNED AS AN EXTRINSIC
|
||||
; BOTH V1 AND V2 ARE PASSED BY REFERENCE
|
||||
N VSRT ; TEMP FOR HASHING DATES
|
||||
N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2
|
||||
S ZCNT=V2(0) ; COUNTING NUMBER OF DATES
|
||||
F ZI=1:1:ZCNT D ; FOR EACH DATE IN THE ARRAY
|
||||
. I $D(V2(ZI)) D ; IF THE DATE EXISTS
|
||||
. . S ZP1=$P(V2(ZI),".",1) ; THE DATE PIECE
|
||||
. . S ZP2=$P(V2(ZI),".",2) ; THE TIME PIECE
|
||||
. . ; W "DATE: ",ZP1," TIME: ",ZP2,!
|
||||
. . S VSRT(ZP1,ZP2,ZI)=ZI ; INDEX OF DATE, TIME AND COUNT
|
||||
N ZG
|
||||
S ZG=$Q(VSRT(""))
|
||||
F D Q:ZG="" ;
|
||||
. ; W ZG,!
|
||||
. D PUSH^GPLXPATH("V1",@ZG)
|
||||
. S ZG=$Q(@ZG)
|
||||
I ORDR=-1 D ; HAVE TO REVERSE ORDER
|
||||
. N ZG2
|
||||
. F ZI=1:1:V1(0) D ; FOR EACH ELELMENT
|
||||
. . S ZG2(V1(0)-ZI+1)=V1(ZI) ; SET IN REVERSE ORDER
|
||||
. S ZG2(0)=V1(0)
|
||||
. D CP^GPLXPATH("ZG2","V1") ; COPY OVER THE NEW ARRAY
|
||||
Q ZCNT
|
||||
;
|
||||
DA2SNO(RTN,DNAME) ; LOOK UP DRUG ALLERGY CODE IN ^LEX
|
||||
; RETURNS AN ARRAY RTN PASSED BY REFERENCE
|
||||
; THIS ROUTINE CAN BE USED AS AN RPC
|
||||
; RTN(0) IS THE NUMBER OF ELEMENTS IN THE ARRAY
|
||||
; RTN(1) IS THE SNOMED CODE FOR THE DRUG ALLERGY
|
||||
;
|
||||
N LEXIEN
|
||||
I $O(^LEX(757.21,"ADIS",DNAME,""))'="" D ; IEN FOUND FOR THIS DRUG
|
||||
. S LEXIEN=$O(^LEX(757.21,"ADIS",DNAME,"")) ; GET THE IEN IN THE LEXICON
|
||||
. W LEXIEN,!
|
||||
. S RTN(1)=$P(^LEX(757.02,LEXIEN,0),"^",2) ; SNOMED CODE IN P2
|
||||
. S RTN(0)=1 ; ONE THING RETURNED
|
||||
E S RTN(0)=0 ; NOT FOUND
|
||||
Q
|
||||
;
|
||||
DASNO(DANAME) ; PRINTS THE SNOMED CODE FOR ALLERGY TO DRUG DANAME
|
||||
;
|
||||
N DARTN
|
||||
D DA2SNO(.DARTN,DANAME) ; CALL THE LOOKUP ROUTINE
|
||||
I DARTN(0)>0 D ; GOT RESULTS
|
||||
. W !,DARTN(1) ;PRINT THE SNOMED CODE
|
||||
E W !,"NOT FOUND",!
|
||||
Q
|
||||
;
|
||||
DASNALL(WHICH) ; ROUTINE TO EXAMINE THE ADIS INDEX IN LEX AND RETRIEVE ALL
|
||||
; ASSOCIATED SNOMED CODES
|
||||
N DASTMP,DASIEN,DASNO
|
||||
S DASTMP=""
|
||||
F S DASTMP=$O(^LEX(757.21,WHICH,DASTMP)) Q:DASTMP="" D ; NAME OF MED
|
||||
. S DASIEN=$O(^LEX(757.21,WHICH,DASTMP,"")) ; IEN OF MED
|
||||
. S DASNO=$P(^LEX(757.02,DASIEN,0),"^",2) ; SNOMED CODE FOR ENTRY
|
||||
. W DASTMP,"=",DASNO,! ; PRINT IT OUT
|
||||
Q
|
||||
;
|
||||
RPMS() ; Are we running on an RPMS system rather than Vista?
|
||||
Q $G(DUZ("AG"))="I" ; If User Agency is Indian Health Service
|
||||
VISTA() ; Are we running on Vanilla Vista?
|
||||
Q $G(DUZ("AG"))="V" ; If User Agency is VA
|
||||
WV() ; Are we running on Customized Vista (WV or OpenVista)?
|
||||
Q $G(DUZ("AG"))="E"!($G(DUZ("AG"))="O") ; Codes for WV and Other.
|
||||
C0CUTIL ;WV/C0C/SMH - Various Utilites for generating the CCR/CCD;06/15/08
|
||||
;;0.1;C0C;;Jun 15, 2008;
|
||||
;Copyright 2008-2009 Sam Habiel & George Lilly.
|
||||
;Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
W "No Entry at Top!"
|
||||
Q
|
||||
;
|
||||
FMDTOUTC(DATE,FORMAT) ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrinsic
|
||||
; FORMAT is Format of Date. Can be either D (Day) or DT (Date and Time)
|
||||
; If not passed, or passed incorrectly, it's assumed that it is D.
|
||||
; FM Date format is "YYYMMDD.HHMMSS" HHMMSS may not be supplied.
|
||||
; UTC date is formatted as follows: YYYY-MM-DDThh:mm:ss_offsetfromUTC
|
||||
; UTC, Year, Month, Day, Hours, Minutes, Seconds, Time offset (obtained from Mailman Site Parameters)
|
||||
N UTC,Y,M,D,H,MM,S,OFF
|
||||
S Y=1700+$E(DATE,1,3)
|
||||
S M=$E(DATE,4,5)
|
||||
S D=$E(DATE,6,7)
|
||||
S H=$E(DATE,9,10)
|
||||
I $L(H)=1 S H="0"_H
|
||||
S MM=$E(DATE,11,12)
|
||||
I $L(MM)=1 S MM="0"_MM
|
||||
S S=$E(DATE,13,14)
|
||||
I $L(S)=1 S S="0"_S
|
||||
S OFF=$$TZ^XLFDT ; See Kernel Manual for documentation.
|
||||
S OFFS=$E(OFF,1,1)
|
||||
S OFF0=$TR(OFF,"+-")
|
||||
S OFF1=$E(OFF0+10000,2,3)
|
||||
S OFF2=$E(OFF0+10000,4,5)
|
||||
S OFF=OFFS_OFF1_":"_OFF2
|
||||
;S OFF2=$E(OFF,1,2) ;
|
||||
;S OFF2=$E(100+OFF2,2,3) ; GPL 11/08 CHANGED TO -05:00 FORMAT
|
||||
;S OFF3=$E(OFF,3,4) ;MINUTES
|
||||
;S OFF=$S(OFF2="":"00",0:"00",1:OFF2)_"."_$S(OFF3="":"00",1:OFF3)
|
||||
; If H, MM and S are empty, it means that the FM date didn't supply the time.
|
||||
; In this case, set H, MM and S to "00"
|
||||
; S:('$L(H)&'$L(MM)&'$L(S)) (H,MM,S)="00" ; IF ONLY SOME ARE MISSING?
|
||||
S:'$L(H) H="00"
|
||||
S:'$L(MM) MM="00"
|
||||
S:'$L(S) S="00"
|
||||
S UTC=Y_"-"_M_"-"_D_"T"_H_":"_MM_$S(S="":":00",1:":"_S)_OFF ; Skip's code to fix hanging colon if no seconds
|
||||
I $L($G(FORMAT)),FORMAT="DT" Q UTC ; Date with time.
|
||||
E Q $P(UTC,"T")
|
||||
;
|
||||
SORTDT(V1,V2,ORDR) ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT
|
||||
; AS EXTRINSIC ORDR IS 1 OR -1 FOR FORWARD OR REVERSE
|
||||
; DATE AND TIME ORDER. DEFAULT IS FORWARD
|
||||
; V2 IS AN ARRAY OF DATES IN FILEMAN FORMAT
|
||||
; V1 IS RETURNS INDIRECT INDEXES OF V2 IN REVERSE DATE ORDER
|
||||
; SO V2(V1(X)) WILL RETURN THE DATES IN DATE/TIME ORDER
|
||||
; THE COUNT OF THE DATES IS RETURNED AS AN EXTRINSIC
|
||||
; BOTH V1 AND V2 ARE PASSED BY REFERENCE
|
||||
N VSRT ; TEMP FOR HASHING DATES
|
||||
N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2
|
||||
S ZCNT=V2(0) ; COUNTING NUMBER OF DATES
|
||||
F ZI=1:1:ZCNT D ; FOR EACH DATE IN THE ARRAY
|
||||
. I $D(V2(ZI)) D ; IF THE DATE EXISTS
|
||||
. . S ZP1=$P(V2(ZI),".",1) ; THE DATE PIECE
|
||||
. . S ZP2=$P(V2(ZI),".",2) ; THE TIME PIECE
|
||||
. . ; W "DATE: ",ZP1," TIME: ",ZP2,!
|
||||
. . S VSRT(ZP1,ZP2,ZI)=ZI ; INDEX OF DATE, TIME AND COUNT
|
||||
N ZG
|
||||
S ZG=$Q(VSRT(""))
|
||||
F D Q:ZG="" ;
|
||||
. ; W ZG,!
|
||||
. D PUSH^GPLXPATH("V1",@ZG)
|
||||
. S ZG=$Q(@ZG)
|
||||
I ORDR=-1 D ; HAVE TO REVERSE ORDER
|
||||
. N ZG2
|
||||
. F ZI=1:1:V1(0) D ; FOR EACH ELELMENT
|
||||
. . S ZG2(V1(0)-ZI+1)=V1(ZI) ; SET IN REVERSE ORDER
|
||||
. S ZG2(0)=V1(0)
|
||||
. D CP^GPLXPATH("ZG2","V1") ; COPY OVER THE NEW ARRAY
|
||||
Q ZCNT
|
||||
;
|
||||
DA2SNO(RTN,DNAME) ; LOOK UP DRUG ALLERGY CODE IN ^LEX
|
||||
; RETURNS AN ARRAY RTN PASSED BY REFERENCE
|
||||
; THIS ROUTINE CAN BE USED AS AN RPC
|
||||
; RTN(0) IS THE NUMBER OF ELEMENTS IN THE ARRAY
|
||||
; RTN(1) IS THE SNOMED CODE FOR THE DRUG ALLERGY
|
||||
;
|
||||
N LEXIEN
|
||||
I $O(^LEX(757.21,"ADIS",DNAME,""))'="" D ; IEN FOUND FOR THIS DRUG
|
||||
. S LEXIEN=$O(^LEX(757.21,"ADIS",DNAME,"")) ; GET THE IEN IN THE LEXICON
|
||||
. W LEXIEN,!
|
||||
. S RTN(1)=$P(^LEX(757.02,LEXIEN,0),"^",2) ; SNOMED CODE IN P2
|
||||
. S RTN(0)=1 ; ONE THING RETURNED
|
||||
E S RTN(0)=0 ; NOT FOUND
|
||||
Q
|
||||
;
|
||||
DASNO(DANAME) ; PRINTS THE SNOMED CODE FOR ALLERGY TO DRUG DANAME
|
||||
;
|
||||
N DARTN
|
||||
D DA2SNO(.DARTN,DANAME) ; CALL THE LOOKUP ROUTINE
|
||||
I DARTN(0)>0 D ; GOT RESULTS
|
||||
. W !,DARTN(1) ;PRINT THE SNOMED CODE
|
||||
E W !,"NOT FOUND",!
|
||||
Q
|
||||
;
|
||||
DASNALL(WHICH) ; ROUTINE TO EXAMINE THE ADIS INDEX IN LEX AND RETRIEVE ALL
|
||||
; ASSOCIATED SNOMED CODES
|
||||
N DASTMP,DASIEN,DASNO
|
||||
S DASTMP=""
|
||||
F S DASTMP=$O(^LEX(757.21,WHICH,DASTMP)) Q:DASTMP="" D ; NAME OF MED
|
||||
. S DASIEN=$O(^LEX(757.21,WHICH,DASTMP,"")) ; IEN OF MED
|
||||
. S DASNO=$P(^LEX(757.02,DASIEN,0),"^",2) ; SNOMED CODE FOR ENTRY
|
||||
. W DASTMP,"=",DASNO,! ; PRINT IT OUT
|
||||
Q
|
||||
;
|
||||
RPMS() ; Are we running on an RPMS system rather than Vista?
|
||||
Q $G(DUZ("AG"))="I" ; If User Agency is Indian Health Service
|
||||
VISTA() ; Are we running on Vanilla Vista?
|
||||
Q $G(DUZ("AG"))="V" ; If User Agency is VA
|
||||
WV() ; Are we running on WorldVista?
|
||||
Q $G(DUZ("AG"))="E" ; Code for WV.
|
||||
OV() ; Are we running on OpenVista?
|
||||
Q $G(DUZ("AG"))="O" ; Code for OpenVista
|
||||
|
|
Loading…
Reference in New Issue