source: ccr/trunk/p/C0CNMED2.m@ 1744

Last change on this file since 1744 was 1586, checked in by Sam Habiel, 12 years ago

Changed license to AGPL. Some clean-up for XINDEX

  • Property svn:mergeinfo set to (toggle deleted branches)
    /ccr/branches/ohum/o-old/p/C0CNMED2.m1290
    /ccr/branches/ohum/p/C0CNMED2.m1291-1543
    /ccr/branches/ohum/p/p/C0CNMED2.m1287-1289
File size: 5.7 KB
Line 
1C0CNMED2 ; WV/CCDCCR/GPL/SMH - CCR/CCD Medications Driver; Mar 23 2009 ; 5/10/12 2:53pm
2 ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
3 ; Copyright 2008,2009 George Lilly, University of Minnesota and Sam Habiel.
4 ;
5 ; This program is free software: you can redistribute it and/or modify
6 ; it under the terms of the GNU Affero General Public License as
7 ; published by the Free Software Foundation, either version 3 of the
8 ; License, or (at your option) any later version.
9 ;
10 ; This program is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU Affero General Public License for more details.
14 ;
15 ; You should have received a copy of the GNU Affero General Public License
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
17 ;
18 ;
19 ; --Revision History
20 ; July 2008 - Initial Version/GPL
21 ; July 2008 - March 2009 various revisions
22 ; March 2009 - Reconstruction of routine as driver for other med routines/SMH
23 ; June 2011 - Redone to support all meds using the FOIA NHIN routines/gpl
24 ;
25 Q
26 ;
27 ; THIS VERSION IS DEPRECATED BECAUSE IT DOES NOT GENEREATE XML IN
28 ; THE RIGHT ORDER... AND IT HAS TO BE IN THE RIGHT ORDER... :(
29 ; GPL
30 ;
31EXTRACT(MEDXML,DFN,MEDOUTXML) ; Private; Extract medications into provided XML template
32 ; DFN passed by reference
33 ; MEDXML and MEDOUTXML are passed by Name
34 ; MEDXML is the input template
35 ; MEDOUTXML is the output template
36 ; Both of them refer to ^TMP globals where the XML documents are stored
37 ;
38 N GN
39 D EN^C0CNHIN(.GN,DFN,"MED;",1) ; RETRIEVE NHIN ARRAY OF MEDS
40 ; this call uses GET^NHINV to retrieve xml of the meds and then
41 ; parses with MXML and uses DOMO^C0CDOM to extract an NHIN array
42 ;
43 ; we now create an NHIN Array of the Meds section of the CCR
44 ;
45 N ZI S ZI=""
46 F S ZI=$O(GN("med",ZI)) Q:ZI="" D ; for each med
47 . N GA S GA=$NA(GN("med",ZI))
48 . N GM S GM="Medication" ; to keep the lines shorter
49 . S GC(GM,ZI,"CCRDataObjectID")="MED_"_ZI
50 . N ZD,ZD2 S ZD=$G(@GA@("ordered@value")) ; FILEMAN DATE
51 . I ZD="" S ZD=$G(@GA@("start@value")) ; for inpatient meds
52 . S ZD2=$$FMDTOUTC^C0CUTIL(ZD,"DT")
53 . S GC(GM,ZI,"DateTime[1].ExactDateTime")=ZD2
54 . S GC(GM,ZI,"DateTime[1].Type.Text")="Documented Date"
55 . ;S GC(GM,ZI,"DateTime[2].ExactDateTime")=""
56 . ;S GC(GM,ZI,"DateTime[2].Type.Text")=""
57 . N GSIG S GSIG=$G(@GA@("sig"))
58 . I GSIG["|" S GSIG=$P(GSIG,"|",2) ; eRx has name of drug separated by |
59 . S GC(GM,ZI,"Description.Text")=GSIG
60 . N GD S GD="Directions.Direction" ; MAKING THE STRINGS SHORTER
61 . ;S GC(GM,ZI,GD_".DeliveryMethod.Text")="@@MEDDELIVERYMETHOD@@"
62 . ;S GC(GM,ZI,GD_".Description.Text")=""
63 . ;S GC(GM,ZI,GD_".DirectionSequenceModifier")="@@MEDDIRSEQ@@"
64 . ;S GC(GM,ZI,GD_".Dose.Rate.Units.Unit")="@@MEDRATEUNIT@@"
65 . ;S GC(GM,ZI,GD_".Dose.Rate.Value")="@@MEDRATEVALUE@@"
66 . ;S GC(GM,ZI,GD_".Dose.Units.Unit")="@@MEDDOSEUNIT@@"
67 . ;S GC(GM,ZI,GD_".Dose.Value")="@@MEDDOSEVALUE@@"
68 . ;S GC(GM,ZI,GD_".DoseIndicator.Text")="@@MEDDOSEINDICATOR@@"
69 . ;S GC(GM,ZI,GD_".Duration.Units.Unit")="@@MEDDURATIONUNIT@@"
70 . ;S GC(GM,ZI,GD_".Duration.Value")="@@MEDDURATIONVALUE@@"
71 . ;S GC(GM,ZI,GD_".Frequency.Value")="@@MEDFREQUENCYVALUE@@"
72 . ;S GC(GM,ZI,GD_".Indication.PRNFlag.Text")="@@MEDPRNFLAG@@"
73 . ;S GC(GM,ZI,GD_".Indication.Problem.CCRDataObjectID")=""
74 . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.CodingSystem")=""
75 . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.Value")=""
76 . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.Version")=""
77 . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Text")=""
78 . ;S GC(GM,ZI,GD_".Indication.Problem.Source.Actor.ActorID")=""
79 . ;S GC(GM,ZI,GD_".Indication.Problem.Type.Text")=""
80 . ;S GC(GM,ZI,GD_".Interval.Units.Unit")="@@MEDINTERVALUNIT@@"
81 . ;S GC(GM,ZI,GD_".Interval.Value")="@@MEDINTERVALVALUE@@"
82 . ;S GC(GM,ZI,GD_".MultipleDirectionModifier.Text")="@@MEDMULDIRMOD@@"
83 . S GC(GM,ZI,GD_".Route.Text")=$G(@GA@("doses.dose@route"))
84 . ;S GC(GM,ZI,GD_".StopIndicator.Text")="@@MEDSTOPINDICATOR@@"
85 . ;S GC(GM,ZI,GD_".Vehicle.Text")="@@MEDVEHICLETEXT@@"
86 . ;S GC(GM,ZI,"FullfillmentInstructions.Text")=""
87 . ;S GC(GM,ZI,"IDs.ID")="@@MEDRXNO@@"
88 . ;S GC(GM,ZI,"IDs.Type.Text")="@@MEDRXNOTXT@@"
89 . ;S GC(GM,ZI,"PatientInstructions.Instruction.Text")="@@MEDPTINSTRUCTIONS@@"
90 . ;S GC(GM,ZI,"Product.BrandName.Text")="@@MEDBRANDNAMETEXT@@"
91 . S GC(GM,ZI,"Product.Concentration.Units.Unit")=$G(@GA@("doses.dose@units"))
92 . S GC(GM,ZI,"Product.Concentration.Value")=$G(@GA@("doses.dose@dose"))
93 . S GC(GM,ZI,"Product.Form.Text")=$G(@GA@("form@value"))
94 . N GV S GV=$G(@GA@("products.product.vaProduct@vuid"))
95 . N GR S GR=$$RXNCUI3^C0PLKUP(GV)
96 . S GC(GM,ZI,"Product.ProductName.Code.CodingSystem")=$S(GR:"RxNorm",1:"VUID")
97 . S GC(GM,ZI,"Product.ProductName.Code.Value")=$S(GR:GR,1:GV)
98 . S GC(GM,ZI,"Product.ProductName.Code.Version")="08AB_081201F"
99 . S GC(GM,ZI,"Product.ProductName.Text")=$G(@GA@("name@value"))
100 . S GC(GM,ZI,"Product.Strength.Units.Unit")=$G(@GA@("doses.dose@units"))
101 . S GC(GM,ZI,"Product.Strength.Value")=$G(@GA@("doses.dose@dose"))
102 . ;S GC(GM,ZI,"Quantity.Units.Unit")="@@MEDQUANTITYUNIT@@"
103 . ;S GC(GM,ZI,"Quantity.Value")="@@MEDQUANTITYVALUE@@"
104 . ;S GC(GM,ZI,"Refills.Refill.Number")="@@MEDRFNO@@"
105 . N GDUZ S GDUZ=$G(@GA@("orderingProvider@code")) ;PROVIDER DUZ
106 . S GC(GM,ZI,"Source.Actor.ActorID")="PROVIDER_"_GDUZ
107 . S GC(GM,ZI,"Status.Text")=$G(@GA@("status@value"))
108 . S GC(GM,ZI,"Type.Text")="Medication"
109 N C0CDOCID
110 S C0CDOCID=$$DOMI^C0CDOM("GC",,"Medications") ; insert to dom
111 D OUTXML^C0CDOM(MEDOUTXML,C0CDOCID,1) ; render the xml
112 N ZSIZE S ZSIZE=$O(@MEDOUTXML@(""),-1)
113 S @MEDOUTXML@(0)=ZSIZE ; RETURN STATUS IS NUMBER OF LINES OF XML
114 W !,MEDOUTXML
115 ;ZWR GN
116 ;ZWR GC
117 ;B
118 Q
119 ;
Note: See TracBrowser for help on using the repository browser.