source: ePrescribing/trunk/p/C0PSMEDS.m@ 1676

Last change on this file since 1676 was 1595, checked in by George Lilly, 12 years ago

initial release of ePrescribing

File size: 3.0 KB
Line 
1C0PSMEDS ; ERX/GPL - Utilities for eRx SendMeds; 3/1/11
2 ;;1.0;C0P;;Apr 25, 2012;Build 103
3 ;Copyright 2011 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 Q
21 ;
22ADD(RTNXML,G6) ; ADD SENDMEDS TO THE NCSCRIPT XML
23 N GEND,ZG1,G5,GBLD
24 M ZG1=@RTNXML
25 S GEND=$O(ZG1(""),-1)-1
26 D QUEUE^C0CXPATH("GBLD","ZG1",1,GEND) ; NCSCRIPT.. UP TO </NCScript>
27 D QUEUE^C0CXPATH("GBLD",G6,1,$O(@G6@(""),-1)) ; ADD THE MEDS
28 D QUEUE^C0CXPATH("GBLD","ZG1",GEND+1,GEND+1) ;END OF NCSCRIPT
29 D BUILD^C0CXPATH("GBLD","G5") ; BUILD THE CONTENTS FROM THE BUILD LIST
30 K @RTNXML
31 M @RTNXML=G5 ;
32 Q
33 ;
34FREETXT(RXML,ZDUZ,ZDFN) ; ADD FREE TEXT MEDS FOR PATIENT ZDFN TO RXML,
35 ; PASSED BY NAME; ZDUZ IS PASSED TO RESOLVE THE TEMPLATE
36 N ZTID,ZMEDS,ZI,ZN,ZTMP,ZVARS,ZBLD,ZNM
37 S ZTID=$$RESTID^C0PWS1(ZDUZ,"FREE TEXT MEDS") ;GET TEMPLATE ID
38 D GET^C0PCUR(.ZMEDS,ZDFN) ; GET THE PATIENT'S CURRENT MEDS
39 S ZN=$O(ZMEDS(""),-1) ; COUNT OF MEDS
40 I +ZN=0 Q ; NO MEDS, QUIT
41 F ZI=1:1:ZN D ; FOR EACH MED
42 . N ZCMT
43 . S ZCMT=$G(ZMEDS(ZI,"COMMENTS",1))
44 . I ZCMT["E-Rx" Q ; SKIP eRx MEDS
45 . I ZCMT["Received by" Q ; SKIP eRx Meds
46 . I $P(ZMEDS(ZI,0),"^",9)'="ACTIVE" Q ; ONLY WANT ACTIVE DRUGS
47 . ; GET TYPE OF DRUG
48 . N ZTYP
49 . S ZTYP=$P($P(ZMEDS(ZI,0),"^",1),";",2) ; SHOULD BE AN I OR O
50 . I ZTYP="I" Q ; DON'T WANT INPATIENT MEDS
51 . S ZNM=$NA(ZTMP(ZI)) ; PLACE TO PUT THIS MED XML
52 . N ZDATE
53 . S ZDATE=$G(ZMEDS(ZI,"START"))
54 . I ZDATE'="" D ; TRANSLATE FM DATE TO YYYYMMDD
55 . . S ZDATE=$$FMDTOUTC^C0CUTIL(ZDATE,"D")
56 . . S ZDATE=$TR(ZDATE,"-") ;REMOVE DASHES FROM DOB
57 . I ZDATE="" S ZDATE=""
58 . S ZVARS("date")=ZDATE
59 . S ZVARS("dispenseNumber")=0
60 . S ZVARS("doctorName")=$P($G(ZMEDS(ZI,"P",0)),"^",2)
61 . S ZVARS("drug")=$P(ZMEDS(ZI,0),"^",2) ; NAME OF THE MED
62 . N ZEXID
63 . S ZEXID=$G(ZMEDS(ZI,"NVAIEN"))
64 . I ZEXID="" S ZEXID="MED_"_$G(ZMEDS(ZI,"DRUG")) ; THE MED NUMBER
65 . S ZVARS("externalId")=ZEXID
66 . S ZVARS("prescriptionType")="reconcile"
67 . S ZVARS("refillCount")=0
68 . S ZVARS("sig")=$G(ZMEDS(ZI,"SIG",1,0))
69 . S ZVARS("sig")=$TR(ZVARS("sig"),"'")
70 . D MAP^C0PMAIN(ZNM,"ZVARS",ZTID) ; GENERATE XML FOR 1 MED
71 . ;B
72 . D QUEUE^C0CXPATH("ZBLD",ZNM,1,@ZNM@(0)) ; ADD TO BUILD LIST
73 I +$D(ZBLD)=0 Q ; NO NON-ERX MEDS
74 D BUILD^C0CXPATH("ZBLD",RXML) ; BUILD ALL THE MEDS
75 Q
76 ;
Note: See TracBrowser for help on using the repository browser.