Ignore:
Timestamp:
May 11, 2012, 6:06:25 PM (13 years ago)
Author:
Sam Habiel
Message:

Update of all routines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/branches/ohum/p/C0CNMED2.m

    r1342 r1428  
    1 C0CMED ; WV/CCDCCR/GPL/SMH - CCR/CCD Medications Driver; Mar 23 2009
    2  ;;1.0;C0C;;May 19, 2009;Build 2
    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  ; June 2011 - Redone to support all meds using the FOIA NHIN routines/gpl
    26  ;
    27  Q
    28  ;
    29  ; THIS VERSION IS DEPRECATED BECAUSE IT DOES NOT GENEREATE XML IN
    30  ; THE RIGHT ORDER... AND IT HAS TO BE IN THE RIGHT ORDER... :(
    31  ; GPL
    32  ;
    33 EXTRACT(MEDXML,DFN,MEDOUTXML) ; Private; Extract medications into provided XML template
    34  ; DFN passed by reference
    35  ; MEDXML and MEDOUTXML are passed by Name
    36  ; MEDXML is the input template
    37  ; MEDOUTXML is the output template
    38  ; Both of them refer to ^TMP globals where the XML documents are stored
    39  ;
    40  N GN
    41  D EN^C0CNHIN(.GN,DFN,"MED;",1) ; RETRIEVE NHIN ARRAY OF MEDS
    42  ; this call uses GET^NHINV to retrieve xml of the meds and then
    43  ; parses with MXML and uses DOMO^C0CDOM to extract an NHIN array
    44  ;
    45  ; we now create an NHIN Array of the Meds section of the CCR
    46  ;
    47  N ZI S ZI=""
    48  F  S ZI=$O(GN("med",ZI)) Q:ZI=""  D  ; for each med
    49  . N GA S GA=$NA(GN("med",ZI))
    50  . N GM S GM="Medication" ; to keep the lines shorter
    51  . S GC(GM,ZI,"CCRDataObjectID")="MED_"_ZI
    52  . N ZD,ZD2 S ZD=$G(@GA@("ordered@value")) ; FILEMAN DATE
    53  . I ZD="" S ZD=$G(@GA@("start@value")) ; for inpatient meds
    54  . S ZD2=$$FMDTOUTC^C0CUTIL(ZD,"DT")
    55  . S GC(GM,ZI,"DateTime[1].ExactDateTime")=ZD2
    56  . S GC(GM,ZI,"DateTime[1].Type.Text")="Documented Date"
    57  . ;S GC(GM,ZI,"DateTime[2].ExactDateTime")=""
    58  . ;S GC(GM,ZI,"DateTime[2].Type.Text")=""
    59  . N GSIG S GSIG=$G(@GA@("sig"))
    60  . I GSIG["|" S GSIG=$P(GSIG,"|",2) ; eRx has name of drug separated by |
    61  . S GC(GM,ZI,"Description.Text")=GSIG
    62  . N GD S GD="Directions.Direction" ; MAKING THE STRINGS SHORTER
    63  . ;S GC(GM,ZI,GD_".DeliveryMethod.Text")="@@MEDDELIVERYMETHOD@@"
    64  . ;S GC(GM,ZI,GD_".Description.Text")=""
    65  . ;S GC(GM,ZI,GD_".DirectionSequenceModifier")="@@MEDDIRSEQ@@"
    66  . ;S GC(GM,ZI,GD_".Dose.Rate.Units.Unit")="@@MEDRATEUNIT@@"
    67  . ;S GC(GM,ZI,GD_".Dose.Rate.Value")="@@MEDRATEVALUE@@"
    68  . ;S GC(GM,ZI,GD_".Dose.Units.Unit")="@@MEDDOSEUNIT@@"
    69  . ;S GC(GM,ZI,GD_".Dose.Value")="@@MEDDOSEVALUE@@"
    70  . ;S GC(GM,ZI,GD_".DoseIndicator.Text")="@@MEDDOSEINDICATOR@@"
    71  . ;S GC(GM,ZI,GD_".Duration.Units.Unit")="@@MEDDURATIONUNIT@@"
    72  . ;S GC(GM,ZI,GD_".Duration.Value")="@@MEDDURATIONVALUE@@"
    73  . ;S GC(GM,ZI,GD_".Frequency.Value")="@@MEDFREQUENCYVALUE@@"
    74  . ;S GC(GM,ZI,GD_".Indication.PRNFlag.Text")="@@MEDPRNFLAG@@"
    75  . ;S GC(GM,ZI,GD_".Indication.Problem.CCRDataObjectID")=""
    76  . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.CodingSystem")=""
    77  . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.Value")=""
    78  . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.Version")=""
    79  . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Text")=""
    80  . ;S GC(GM,ZI,GD_".Indication.Problem.Source.Actor.ActorID")=""
    81  . ;S GC(GM,ZI,GD_".Indication.Problem.Type.Text")=""
    82  . ;S GC(GM,ZI,GD_".Interval.Units.Unit")="@@MEDINTERVALUNIT@@"
    83  . ;S GC(GM,ZI,GD_".Interval.Value")="@@MEDINTERVALVALUE@@"
    84  . ;S GC(GM,ZI,GD_".MultipleDirectionModifier.Text")="@@MEDMULDIRMOD@@"
    85  . S GC(GM,ZI,GD_".Route.Text")=$G(@GA@("doses.dose@route"))
    86  . ;S GC(GM,ZI,GD_".StopIndicator.Text")="@@MEDSTOPINDICATOR@@"
    87  . ;S GC(GM,ZI,GD_".Vehicle.Text")="@@MEDVEHICLETEXT@@"
    88  . ;S GC(GM,ZI,"FullfillmentInstructions.Text")=""
    89  . ;S GC(GM,ZI,"IDs.ID")="@@MEDRXNO@@"
    90  . ;S GC(GM,ZI,"IDs.Type.Text")="@@MEDRXNOTXT@@"
    91  . ;S GC(GM,ZI,"PatientInstructions.Instruction.Text")="@@MEDPTINSTRUCTIONS@@"
    92  . ;S GC(GM,ZI,"Product.BrandName.Text")="@@MEDBRANDNAMETEXT@@"
    93  . S GC(GM,ZI,"Product.Concentration.Units.Unit")=$G(@GA@("doses.dose@units"))
    94  . S GC(GM,ZI,"Product.Concentration.Value")=$G(@GA@("doses.dose@dose"))
    95  . S GC(GM,ZI,"Product.Form.Text")=$G(@GA@("form@value"))
    96  . N GV S GV=$G(@GA@("products.product.vaProduct@vuid"))
    97  . N GR S GR=$$RXNCUI3^C0PLKUP(GV)
    98  . S GC(GM,ZI,"Product.ProductName.Code.CodingSystem")=$S(GR:"RxNorm",1:"VUID")
    99  . S GC(GM,ZI,"Product.ProductName.Code.Value")=$S(GR:GR,1:GV)
    100  . S GC(GM,ZI,"Product.ProductName.Code.Version")="08AB_081201F"
    101  . S GC(GM,ZI,"Product.ProductName.Text")=$G(@GA@("name@value"))
    102  . S GC(GM,ZI,"Product.Strength.Units.Unit")=$G(@GA@("doses.dose@units"))
    103  . S GC(GM,ZI,"Product.Strength.Value")=$G(@GA@("doses.dose@dose"))
    104  . ;S GC(GM,ZI,"Quantity.Units.Unit")="@@MEDQUANTITYUNIT@@"
    105  . ;S GC(GM,ZI,"Quantity.Value")="@@MEDQUANTITYVALUE@@"
    106  . ;S GC(GM,ZI,"Refills.Refill.Number")="@@MEDRFNO@@"
    107  . N GDUZ S GDUZ=$G(@GA@("orderingProvider@code")) ;PROVIDER DUZ
    108  . S GC(GM,ZI,"Source.Actor.ActorID")="PROVIDER_"_GDUZ
    109  . S GC(GM,ZI,"Status.Text")=$G(@GA@("status@value"))
    110  . S GC(GM,ZI,"Type.Text")="Medication"
    111  N C0CDOCID
    112  S C0CDOCID=$$DOMI^C0CDOM("GC",,"Medications") ; insert to dom
    113  D OUTXML^C0CDOM(MEDOUTXML,C0CDOCID,1) ; render the xml
    114  N ZSIZE S ZSIZE=$O(@MEDOUTXML@(""),-1)
    115  S @MEDOUTXML@(0)=ZSIZE ; RETURN STATUS IS NUMBER OF LINES OF XML
    116  W !,MEDOUTXML
    117  ;ZWR GN
    118  ;ZWR GC
    119  ;B
    120  Q
    121  ;
     1C0CNMED2        ; WV/CCDCCR/GPL/SMH - CCR/CCD Medications Driver; Mar 23 2009 ; 5/10/12 2:53pm
     2        ;;1.2;C0C;;May 11, 2012;Build 46
     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        ; June 2011 - Redone to support all meds using the FOIA NHIN routines/gpl
     26        ;
     27        Q
     28        ;
     29        ; THIS VERSION IS DEPRECATED BECAUSE IT DOES NOT GENEREATE XML IN
     30        ; THE RIGHT ORDER... AND IT HAS TO BE IN THE RIGHT ORDER... :(
     31        ; GPL
     32        ;
     33EXTRACT(MEDXML,DFN,MEDOUTXML)   ; Private; Extract medications into provided XML template
     34        ; DFN passed by reference
     35        ; MEDXML and MEDOUTXML are passed by Name
     36        ; MEDXML is the input template
     37        ; MEDOUTXML is the output template
     38        ; Both of them refer to ^TMP globals where the XML documents are stored
     39        ;
     40        N GN
     41        D EN^C0CNHIN(.GN,DFN,"MED;",1) ; RETRIEVE NHIN ARRAY OF MEDS
     42        ; this call uses GET^NHINV to retrieve xml of the meds and then
     43        ; parses with MXML and uses DOMO^C0CDOM to extract an NHIN array
     44        ;
     45        ; we now create an NHIN Array of the Meds section of the CCR
     46        ;
     47        N ZI S ZI=""
     48        F  S ZI=$O(GN("med",ZI)) Q:ZI=""  D  ; for each med
     49        . N GA S GA=$NA(GN("med",ZI))
     50        . N GM S GM="Medication" ; to keep the lines shorter
     51        . S GC(GM,ZI,"CCRDataObjectID")="MED_"_ZI
     52        . N ZD,ZD2 S ZD=$G(@GA@("ordered@value")) ; FILEMAN DATE
     53        . I ZD="" S ZD=$G(@GA@("start@value")) ; for inpatient meds
     54        . S ZD2=$$FMDTOUTC^C0CUTIL(ZD,"DT")
     55        . S GC(GM,ZI,"DateTime[1].ExactDateTime")=ZD2
     56        . S GC(GM,ZI,"DateTime[1].Type.Text")="Documented Date"
     57        . ;S GC(GM,ZI,"DateTime[2].ExactDateTime")=""
     58        . ;S GC(GM,ZI,"DateTime[2].Type.Text")=""
     59        . N GSIG S GSIG=$G(@GA@("sig"))
     60        . I GSIG["|" S GSIG=$P(GSIG,"|",2) ; eRx has name of drug separated by |
     61        . S GC(GM,ZI,"Description.Text")=GSIG
     62        . N GD S GD="Directions.Direction" ; MAKING THE STRINGS SHORTER
     63        . ;S GC(GM,ZI,GD_".DeliveryMethod.Text")="@@MEDDELIVERYMETHOD@@"
     64        . ;S GC(GM,ZI,GD_".Description.Text")=""
     65        . ;S GC(GM,ZI,GD_".DirectionSequenceModifier")="@@MEDDIRSEQ@@"
     66        . ;S GC(GM,ZI,GD_".Dose.Rate.Units.Unit")="@@MEDRATEUNIT@@"
     67        . ;S GC(GM,ZI,GD_".Dose.Rate.Value")="@@MEDRATEVALUE@@"
     68        . ;S GC(GM,ZI,GD_".Dose.Units.Unit")="@@MEDDOSEUNIT@@"
     69        . ;S GC(GM,ZI,GD_".Dose.Value")="@@MEDDOSEVALUE@@"
     70        . ;S GC(GM,ZI,GD_".DoseIndicator.Text")="@@MEDDOSEINDICATOR@@"
     71        . ;S GC(GM,ZI,GD_".Duration.Units.Unit")="@@MEDDURATIONUNIT@@"
     72        . ;S GC(GM,ZI,GD_".Duration.Value")="@@MEDDURATIONVALUE@@"
     73        . ;S GC(GM,ZI,GD_".Frequency.Value")="@@MEDFREQUENCYVALUE@@"
     74        . ;S GC(GM,ZI,GD_".Indication.PRNFlag.Text")="@@MEDPRNFLAG@@"
     75        . ;S GC(GM,ZI,GD_".Indication.Problem.CCRDataObjectID")=""
     76        . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.CodingSystem")=""
     77        . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.Value")=""
     78        . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Code.Version")=""
     79        . ;S GC(GM,ZI,GD_".Indication.Problem.Description.Text")=""
     80        . ;S GC(GM,ZI,GD_".Indication.Problem.Source.Actor.ActorID")=""
     81        . ;S GC(GM,ZI,GD_".Indication.Problem.Type.Text")=""
     82        . ;S GC(GM,ZI,GD_".Interval.Units.Unit")="@@MEDINTERVALUNIT@@"
     83        . ;S GC(GM,ZI,GD_".Interval.Value")="@@MEDINTERVALVALUE@@"
     84        . ;S GC(GM,ZI,GD_".MultipleDirectionModifier.Text")="@@MEDMULDIRMOD@@"
     85        . S GC(GM,ZI,GD_".Route.Text")=$G(@GA@("doses.dose@route"))
     86        . ;S GC(GM,ZI,GD_".StopIndicator.Text")="@@MEDSTOPINDICATOR@@"
     87        . ;S GC(GM,ZI,GD_".Vehicle.Text")="@@MEDVEHICLETEXT@@"
     88        . ;S GC(GM,ZI,"FullfillmentInstructions.Text")=""
     89        . ;S GC(GM,ZI,"IDs.ID")="@@MEDRXNO@@"
     90        . ;S GC(GM,ZI,"IDs.Type.Text")="@@MEDRXNOTXT@@"
     91        . ;S GC(GM,ZI,"PatientInstructions.Instruction.Text")="@@MEDPTINSTRUCTIONS@@"
     92        . ;S GC(GM,ZI,"Product.BrandName.Text")="@@MEDBRANDNAMETEXT@@"
     93        . S GC(GM,ZI,"Product.Concentration.Units.Unit")=$G(@GA@("doses.dose@units"))
     94        . S GC(GM,ZI,"Product.Concentration.Value")=$G(@GA@("doses.dose@dose"))
     95        . S GC(GM,ZI,"Product.Form.Text")=$G(@GA@("form@value"))
     96        . N GV S GV=$G(@GA@("products.product.vaProduct@vuid"))
     97        . N GR S GR=$$RXNCUI3^C0PLKUP(GV)
     98        . S GC(GM,ZI,"Product.ProductName.Code.CodingSystem")=$S(GR:"RxNorm",1:"VUID")
     99        . S GC(GM,ZI,"Product.ProductName.Code.Value")=$S(GR:GR,1:GV)
     100        . S GC(GM,ZI,"Product.ProductName.Code.Version")="08AB_081201F"
     101        . S GC(GM,ZI,"Product.ProductName.Text")=$G(@GA@("name@value"))
     102        . S GC(GM,ZI,"Product.Strength.Units.Unit")=$G(@GA@("doses.dose@units"))
     103        . S GC(GM,ZI,"Product.Strength.Value")=$G(@GA@("doses.dose@dose"))
     104        . ;S GC(GM,ZI,"Quantity.Units.Unit")="@@MEDQUANTITYUNIT@@"
     105        . ;S GC(GM,ZI,"Quantity.Value")="@@MEDQUANTITYVALUE@@"
     106        . ;S GC(GM,ZI,"Refills.Refill.Number")="@@MEDRFNO@@"
     107        . N GDUZ S GDUZ=$G(@GA@("orderingProvider@code")) ;PROVIDER DUZ
     108        . S GC(GM,ZI,"Source.Actor.ActorID")="PROVIDER_"_GDUZ
     109        . S GC(GM,ZI,"Status.Text")=$G(@GA@("status@value"))
     110        . S GC(GM,ZI,"Type.Text")="Medication"
     111        N C0CDOCID
     112        S C0CDOCID=$$DOMI^C0CDOM("GC",,"Medications") ; insert to dom
     113        D OUTXML^C0CDOM(MEDOUTXML,C0CDOCID,1) ; render the xml
     114        N ZSIZE S ZSIZE=$O(@MEDOUTXML@(""),-1)
     115        S @MEDOUTXML@(0)=ZSIZE ; RETURN STATUS IS NUMBER OF LINES OF XML
     116        W !,MEDOUTXML
     117        ;ZWR GN
     118        ;ZWR GC
     119        ;B
     120        Q
     121        ;
Note: See TracChangeset for help on using the changeset viewer.