First take on implementing paramters for RPMS...

This commit is contained in:
sam 2009-03-29 21:48:58 +00:00
parent 67d0bf0a72
commit 89b7902306
3 changed files with 396 additions and 390 deletions

View File

@ -1,5 +1,5 @@
C0CMED ; WV/CCDCCR/GPL/SMH - CCR/CCD Medications Driver; Mar 23 2009 C0CMED ; WV/CCDCCR/GPL/SMH - CCR/CCD Medications Driver; Mar 23 2009
;;0.5;CCDCCR;;JUL 16,2008; ;;0.6;CCDCCR;;JUL 16,2008;
; Copyright 2008,2009 George Lilly, University of Minnesota and Sam Habiel. ; Copyright 2008,2009 George Lilly, University of Minnesota and Sam Habiel.
; Licensed under the terms of the GNU General Public License. ; Licensed under the terms of the GNU General Public License.
; See attached copy of the License. ; See attached copy of the License.
@ -39,12 +39,14 @@ EXTRACT(MEDXML,DFN,MEDOUTXML) ; Private; Extract medications into provided XML t
; 5. VA Inpatient UD Meds are in C0CMED5 (doesn't exist yet)--March 2009 ; 5. VA Inpatient UD Meds are in C0CMED5 (doesn't exist yet)--March 2009
; 6. RPMS Meds are in C0CMED6. Need to create other routines for subdivisions of RPMS Meds is not known at this time. ; 6. RPMS Meds are in C0CMED6. Need to create other routines for subdivisions of RPMS Meds is not known at this time.
; ;
; --Prep variables ; --Find out what system we are on...
I $$RPMS^C0CUTIL() D RPMS QUIT I $$RPMS^C0CUTIL() D RPMS QUIT
I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VISTA QUIT I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VISTA QUIT
; Extraction Sections ; --Get parameters for meds
N C0CMFLAG
S C0CMFLAG=$$GET^C0CPARMS("MEDALL")_"^"_$$GET^C0CPARMS("MEDLIMIT")_"^"_$$GET^C0CPARMS("MEDACTIVE")_"^"_$$GET^C0CPARMS("MEDPENDING")
RPMS RPMS
D EXTRACT^C0CMED6(MEDXML,DFN,MEDOUTXML) QUIT D EXTRACT^C0CMED6(MEDXML,DFN,MEDOUTXML,C0CMFLAG) QUIT
VISTA VISTA
N MEDCOUNT S MEDCOUNT=0 N MEDCOUNT S MEDCOUNT=0
N HIST S HIST=$NA(^TMP($J,"MED","HIST")) ; Meds already dispensed N HIST S HIST=$NA(^TMP($J,"MED","HIST")) ; Meds already dispensed

View File

@ -1,324 +1,328 @@
C0CMED6 ; WV/CCDCCR/SMH - Meds from RPMS: Outpatient Meds;01/10/09 C0CMED6 ; WV/CCDCCR/SMH - Meds from RPMS: Outpatient Meds;01/10/09
;;0.1;CCDCCR;;JUL 16,2008; ;;0.1;CCDCCR;;JUL 16,2008;
; Copyright 2008 WorldVistA. Licensed under the terms of the GNU ; Copyright 2008 WorldVistA. Licensed under the terms of the GNU
; General Public License See attached copy of the License. ; General Public License See attached copy of the License.
; ;
; This program is free software; you can redistribute it and/or modify ; 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 ; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or ; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version. ; (at your option) any later version.
; ;
; This program is distributed in the hope that it will be useful, ; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of ; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details. ; GNU General Public License for more details.
; ;
; You should have received a copy of the GNU General Public License along ; 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., ; with this program; if not, write to the Free Software Foundation, Inc.,
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
; ;
W "NO ENTRY FROM TOP",! W "NO ENTRY FROM TOP",!
Q Q
; ;
EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE EXTRACT(MINXML,DFN,OUTXML,FLAGS) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
; ;
; MINXML and OUTXML are passed by name so globals can be used ; MINXML and OUTXML are passed by name so globals can be used
; MINXML will contain only the medications skeleton of the overall template ; MINXML will contain only the medications skeleton of the overall template
; ; FLAGS are: MEDALL(bool)^MEDLIMIT(int)^MEDACTIVE(bool)^MEDPENDING(bool)
; MEDS is return array from RPC. ; FLAGS are set-up in C0CMED.
; MAP is a mapping variable map (store result) for each med ;
; MED is holds each array element from MEDS(J), one medicine ; MEDS is return array from RPC.
; J is a counter. ; MAP is a mapping variable map (store result) for each med
; ; MED is holds each array element from MEDS(J), one medicine
; GETRXS^BEHORXFN(ARRAYNAME,DFN,DAYS) will be the the API used. ; J is a counter.
; This API has been developed by Medsphere for IHS for getting ;
; Medications from RPMS. It has most of what we need. ; GETRXS^BEHORXFN(ARRAYNAME,DFN,DAYS) will be the the API used.
; API written by Doug Martin when he worked for Medsphere (thanks Doug!) ; This API has been developed by Medsphere for IHS for getting
; -- ARRAYNAME is passed by name (required) ; Medications from RPMS. It has most of what we need.
; -- DFN is passed by value (required) ; API written by Doug Martin when he worked for Medsphere (thanks Doug!)
; -- DAYS is passed by value (optional; if not passed defaults to 365) ; -- ARRAYNAME is passed by name (required)
; ; -- DFN is passed by value (required)
; Return: ; -- DAYS is passed by value (optional; if not passed defaults to 365)
; ~Type^PharmID^Drug^InfRate^StopDt^RefRem^TotDose^UnitDose^OrderID ;
; ^Status^LastFill^Chronic^Issued^Rx #^Provider^ ; Return:
; Status Reason^DEA Handling ; ~Type^PharmID^Drug^InfRate^StopDt^RefRem^TotDose^UnitDose^OrderID
; ; ^Status^LastFill^Chronic^Issued^Rx #^Provider^
N MEDS,MEDS1,MAP ; Status Reason^DEA Handling
D GETRXS^BEHORXFN("MEDS1",DFN,365) ; Days hard set to 365 ;
; If MEDS1 is not defined, then no meds N MEDS,MEDS1,MAP
I '$D(MEDS1) S @OUTXML@(0)=0 QUIT D GETRXS^BEHORXFN("MEDS1",DFN,$P(FLAGS,U,2)) ; 2nd piece of FLAGS is # of days to retrieve
I DEBUG ZWR MEDS1,MINXML N ALL S ALL=+FLAGS
N MEDCNT S MEDCNT=0 ; Med Count N ACTIVE S ACTIVE=$P(FLAGS,U,3)
; The next line is a super line. It goes through the array return N PENDING S PENDING=$P(FLAGS,U,4)
; and if the first characters are ~OP, it grabs the line. ; If MEDS1 is not defined, then no meds
; This means that line is for a dispensed Outpatient Med. I '$D(MEDS1) S @OUTXML@(0)=0 QUIT
; That line has the metadata about the med that I need. I DEBUG ZWR MEDS1,MINXML
; The next lines, however many, are the med and the sig. N MEDCNT S MEDCNT=0 ; Med Count
; I won't be using those because I have to get the sig parsed exactly. ; The next line is a super line. It goes through the array return
N J S J="" F S J=$O(MEDS1(J)) Q:J="" I $E(MEDS1(J),1,3)="~OP" S MEDCNT=MEDCNT+1 S MEDS(MEDCNT)=MEDS1(J) ; and if the first characters are ~OP, it grabs the line.
K MEDS1 ; This means that line is for a dispensed Outpatient Med.
S MEDMAP=$NA(^TMP("C0CCCR",$J,"MEDMAP")) ; this is the variable map ; That line has the metadata about the med that I need.
S @MEDMAP@(0)=0 ; Initial count of meds ; The next lines, however many, are the med and the sig.
S MEDCNT="" ; Initialize for $Order ; I won't be using those because I have to get the sig parsed exactly.
F S MEDCNT=$O(MEDS(MEDCNT)) Q:MEDCNT="" D ; for each medication in the list N J S J="" F S J=$O(MEDS1(J)) Q:J="" I $E(MEDS1(J),1,3)="~OP" S MEDCNT=MEDCNT+1 S MEDS(MEDCNT)=MEDS1(J)
. I DEBUG W "MEDCNT IS ",MEDCNT,! K MEDS1
. S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCNT)) S MEDCNT="" ; Initialize for $Order
. ; K @MAP DO NOT KILL HERE, WAS CLEARED IN C0CMED F S MEDCNT=$O(MEDS(MEDCNT)) Q:MEDCNT="" D ; for each medication in the list
. S @MEDMAP@(0)=@MEDMAP@(0)+1 ; increment total meds in var array . I 'ALL,ACTIVE,$P(MEDS(MEDCNT),U,10)'="ACTIVE" QUIT
. I DEBUG W "MAP= ",MAP,! . I 'ALL,PENDING,$P(MEDS(MEDCNT),U,10)'="PENDING" QUIT
. S @MAP@("MEDOBJECTID")="MED"_MEDCNT ; MEDCNT FOR ID . I DEBUG W "MEDCNT IS ",MEDCNT,!
. S @MAP@("MEDISSUEDATETXT")="Issue Date" . S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCNT))
. S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($P(MEDS(MEDCNT),U,13)) . ; K @MAP DO NOT KILL HERE, WAS CLEARED IN C0CMED
. S @MAP@("MEDLASTFILLDATETXT")="Last Fill Date" . I DEBUG W "MAP= ",MAP,!
. S @MAP@("MEDLASTFILLDATE")=$$FMDTOUTC^C0CUTIL($P(MEDS(MEDCNT),U,11)) . S @MAP@("MEDOBJECTID")="MED"_MEDCNT ; MEDCNT FOR ID
. S @MAP@("MEDRXNOTXT")="Prescription Number" . S @MAP@("MEDISSUEDATETXT")="Issue Date"
. S @MAP@("MEDRXNO")=$P(MEDS(MEDCNT),U,14) . S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^C0CUTIL($P(MEDS(MEDCNT),U,13))
. S @MAP@("MEDTYPETEXT")="Medication" . S @MAP@("MEDLASTFILLDATETXT")="Last Fill Date"
. S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses . S @MAP@("MEDLASTFILLDATE")=$$FMDTOUTC^C0CUTIL($P(MEDS(MEDCNT),U,11))
. S @MAP@("MEDSTATUSTEXT")=$P(MEDS(MEDCNT),U,10) . S @MAP@("MEDRXNOTXT")="Prescription Number"
. ; Provider only provided in API as text, not DUZ. . S @MAP@("MEDRXNO")=$P(MEDS(MEDCNT),U,14)
. ; We need to get DUZ from filman file 52 (Prescription) . S @MAP@("MEDTYPETEXT")="Medication"
. ; Field 4; IEN is Piece 2 of Meds stripped of trailing characters. . S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses
. ; Note that I will use RXIEN several times later . S @MAP@("MEDSTATUSTEXT")=$P(MEDS(MEDCNT),U,10)
. N RXIEN S RXIEN=+$P(MEDS(MEDCNT),U,2) . ; Provider only provided in API as text, not DUZ.
. S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52,RXIEN,4,"I") . ; We need to get DUZ from filman file 52 (Prescription)
. S @MAP@("MEDPRODUCTNAMETEXT")=$P(MEDS(MEDCNT),U,3) . ; Field 4; IEN is Piece 2 of Meds stripped of trailing characters.
. ; --- RxNorm Stuff . ; Note that I will use RXIEN several times later
. ; 176.001 is the file for Concepts; 176.003 is the file for . N RXIEN S RXIEN=+$P(MEDS(MEDCNT),U,2)
. ; sources (i.e. for RxNorm Version) . S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52,RXIEN,4,"I")
. ; . S @MAP@("MEDPRODUCTNAMETEXT")=$P(MEDS(MEDCNT),U,3)
. ; I use 176.001 for the Vista version of this routine (files 1-3) . ; --- RxNorm Stuff
. ; Since IHS does not have VUID's, I will be getting RxNorm codes . ; 176.001 is the file for Concepts; 176.003 is the file for
. ; using NDCs. My specially crafted index (sounds evil) named "NDC" . ; sources (i.e. for RxNorm Version)
. ; is in file 176.002. The file is called RxNorm NDC to VUID. . ;
. ; Except that I don't need the VUID, but it's there if I need it. . ; I use 176.001 for the Vista version of this routine (files 1-3)
. ; . ; Since IHS does not have VUID's, I will be getting RxNorm codes
. ; We obviously need the NDC. That is easily obtained from the prescription. . ; using NDCs. My specially crafted index (sounds evil) named "NDC"
. ; Field 27 in file 52 . ; is in file 176.002. The file is called RxNorm NDC to VUID.
. N NDC S NDC=$$GET1^DIQ(52,RXIEN,27,"I") . ; Except that I don't need the VUID, but it's there if I need it.
. ; I discovered that file 176.002 might give you two codes for the NDC . ;
. ; One for the Clinical Drug, and one for the ingredient. . ; We obviously need the NDC. That is easily obtained from the prescription.
. ; So the plan is to get the two RxNorm codes, and then find from . ; Field 27 in file 52
. ; file 176.001 which one is the Clinical Drug. . N NDC S NDC=$$GET1^DIQ(52,RXIEN,27,"I")
. ; ... I refactored this into GETRXN . ; I discovered that file 176.002 might give you two codes for the NDC
. N RXNORM,SRCIEN,RXNNAME,RXNVER . ; One for the Clinical Drug, and one for the ingredient.
. I +NDC,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet. . ; So the plan is to get the two RxNorm codes, and then find from
. . S RXNORM=$$GETRXN(NDC) . ; file 176.001 which one is the Clinical Drug.
. . S SRCIEN=$$FIND1^DIC(176.003,,,"RXNORM","B") . ; ... I refactored this into GETRXN
. . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6) . N RXNORM,SRCIEN,RXNNAME,RXNVER
. . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7) . I +NDC,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet.
. ; . . S RXNORM=$$GETRXN(NDC)
. E S (RXNORM,RXNNAME,RXNVER)="" . . S SRCIEN=$$FIND1^DIC(176.003,,,"RXNORM","B")
. ; End if/else block . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6)
. S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM . . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7)
. S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME . ;
. S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER . E S (RXNORM,RXNNAME,RXNVER)=""
. ; --- End RxNorm section . ; End if/else block
. ; . S @MAP@("MEDPRODUCTNAMECODEVALUE")=RXNORM
. ; Brand name is 52 field 6.5 . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=RXNNAME
. S @MAP@("MEDBRANDNAMETEXT")=$$GET1^DIQ(52,RXIEN,6.5) . S @MAP@("MEDPRODUCTNAMECODEVERSION")=RXNVER
. ; . ; --- End RxNorm section
. ; Next I need Med Form (tab, cap etc), strength (250mg) . ;
. ; concentration for liquids (250mg/mL) . ; Brand name is 52 field 6.5
. ; Since IHS does not have any of the new calls that . S @MAP@("MEDBRANDNAMETEXT")=$$GET1^DIQ(52,RXIEN,6.5)
. ; Vista has, I will be doing a crosswalk: . ;
. ; File 52, field 6 is Drug IEN in file 50 . ; Next I need Med Form (tab, cap etc), strength (250mg)
. ; File 50, field 22 is VA Product IEN in file 50.68 . ; concentration for liquids (250mg/mL)
. ; In file 50.68, I will get the following: . ; Since IHS does not have any of the new calls that
. ; -- 1: Dosage Form . ; Vista has, I will be doing a crosswalk:
. ; -- 2: Strength . ; File 52, field 6 is Drug IEN in file 50
. ; -- 3: Units . ; File 50, field 22 is VA Product IEN in file 50.68
. ; -- 8: Dispense Units . ; In file 50.68, I will get the following:
. ; -- Conc is 2 concatenated with 3 . ; -- 1: Dosage Form
. ; . ; -- 2: Strength
. ; *** If Drug is not matched to NDF, then VA Product will be "" *** . ; -- 3: Units
. ; . ; -- 8: Dispense Units
. N MEDIEN S MEDIEN=$$GET1^DIQ(52,RXIEN,6,"I") ; Drug IEN in 50 . ; -- Conc is 2 concatenated with 3
. N VAPROD S VAPROD=$$GET1^DIQ(50,MEDIEN,22,"I") ; VA Product in file 50.68 . ;
. I +VAPROD D . ; *** If Drug is not matched to NDF, then VA Product will be "" ***
. . S @MAP@("MEDSTRENGTHVALUE")=$$GET1^DIQ(50.68,VAPROD,2) . ;
. . S @MAP@("MEDSTRENGTHUNIT")=$$GET1^DIQ(50.68,VAPROD,3) . N MEDIEN S MEDIEN=$$GET1^DIQ(52,RXIEN,6,"I") ; Drug IEN in 50
. . S @MAP@("MEDFORMTEXT")=$$GET1^DIQ(50.68,VAPROD,1) . N VAPROD S VAPROD=$$GET1^DIQ(50,MEDIEN,22,"I") ; VA Product in file 50.68
. . S @MAP@("MEDCONCVALUE")=@MAP@("MEDSTRENGTHVALUE") . I +VAPROD D
. . S @MAP@("MEDCONCUNIT")=@MAP@("MEDSTRENGTHUNIT") . . S @MAP@("MEDSTRENGTHVALUE")=$$GET1^DIQ(50.68,VAPROD,2)
. E D . . S @MAP@("MEDSTRENGTHUNIT")=$$GET1^DIQ(50.68,VAPROD,3)
. . S @MAP@("MEDSTRENGTHVALUE")="" . . S @MAP@("MEDFORMTEXT")=$$GET1^DIQ(50.68,VAPROD,1)
. . S @MAP@("MEDSTRENGTHUNIT")="" . . S @MAP@("MEDCONCVALUE")=@MAP@("MEDSTRENGTHVALUE")
. . S @MAP@("MEDFORMTEXT")="" . . S @MAP@("MEDCONCUNIT")=@MAP@("MEDSTRENGTHUNIT")
. . S @MAP@("MEDCONCVALUE")="" . E D
. . S @MAP@("MEDCONCUNIT")="" . . S @MAP@("MEDSTRENGTHVALUE")=""
. ; End Strengh/Conc stuff . . S @MAP@("MEDSTRENGTHUNIT")=""
. ; . . S @MAP@("MEDFORMTEXT")=""
. ; Quantity is in the prescription, field 7 . . S @MAP@("MEDCONCVALUE")=""
. S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52,RXIEN,7) . . S @MAP@("MEDCONCUNIT")=""
. ; Dispense unit is in the drug file, field 14.5 . ; End Strengh/Conc stuff
. S @MAP@("MEDQUANTITYUNIT")=$$GET1^DIQ(50,MEDIEN,14.5) . ;
. ; . ; Quantity is in the prescription, field 7
. ; --- START OF DIRECTIONS --- . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52,RXIEN,7)
. ; Sig data not in any API :-( Oh yes, you can get the whole thing, but... . ; Dispense unit is in the drug file, field 14.5
. ; we want the components. . S @MAP@("MEDQUANTITYUNIT")=$$GET1^DIQ(50,MEDIEN,14.5)
. ; It's in multiple 113 in the Prescription File (52) . ;
. ; #.01 DOSAGE ORDERED [1F] "20" . ; --- START OF DIRECTIONS ---
. ; #1 DISPENSE UNITS PER DOSE [2N] "1" . ; Sig data not in any API :-( Oh yes, you can get the whole thing, but...
. ; #2 UNITS [3P:50.607] "MG" . ; we want the components.
. ; #3 NOUN [4F] "TABLET" . ; It's in multiple 113 in the Prescription File (52)
. ; #4 DURATION [5F] "10D" . ; #.01 DOSAGE ORDERED [1F] "20"
. ; #5 CONJUNCTION [6S] "AND" . ; #1 DISPENSE UNITS PER DOSE [2N] "1"
. ; #6 ROUTE [7P:51.2] "ORAL" . ; #2 UNITS [3P:50.607] "MG"
. ; #7 SCHEDULE [8F] "BID" . ; #3 NOUN [4F] "TABLET"
. ; #8 VERB [9F] "TAKE" . ; #4 DURATION [5F] "10D"
. ; . ; #5 CONJUNCTION [6S] "AND"
. ; Will use GETS^DIQ to get fields. . ; #6 ROUTE [7P:51.2] "ORAL"
. ; Data comes out like this: . ; #7 SCHEDULE [8F] "BID"
. ; SAMINS(52.0113,"1,23,",.01)=20 . ; #8 VERB [9F] "TAKE"
. ; SAMINS(52.0113,"1,23,",1)=1 . ;
. ; SAMINS(52.0113,"1,23,",2)="MG" . ; Will use GETS^DIQ to get fields.
. ; SAMINS(52.0113,"1,23,",3)="TABLET" . ; Data comes out like this:
. ; SAMINS(52.0113,"1,23,",4)="5D" . ; SAMINS(52.0113,"1,23,",.01)=20
. ; SAMINS(52.0113,"1,23,",5)="THEN" . ; SAMINS(52.0113,"1,23,",1)=1
. ; . ; SAMINS(52.0113,"1,23,",2)="MG"
. N RAWDATA . ; SAMINS(52.0113,"1,23,",3)="TABLET"
. D GETS^DIQ(52,RXIEN,"113*",,"RAWDATA","DIERR") . ; SAMINS(52.0113,"1,23,",4)="5D"
. D:$D(DIERR) ^%ZTER ; Log if there's an error in retrieving sig field . ; SAMINS(52.0113,"1,23,",5)="THEN"
. ; none the less, continue; some parts are retrievable. . ;
. N FMSIG M FMSIG=RAWDATA(52.0113) ; Merge into subfile... . N RAWDATA
. K RAWDATA . D GETS^DIQ(52,RXIEN,"113*",,"RAWDATA","DIERR")
. N FMSIGNUM S FMSIGNUM="" ; Sigline number in fileman. . D:$D(DIERR) ^%ZTER ; Log if there's an error in retrieving sig field
. ; FMSIGNUM gets outputted as "IEN,RXIEN,". . ; none the less, continue; some parts are retrievable.
. ; DIRCNT is the proper Sigline numer. . N FMSIG M FMSIG=RAWDATA(52.0113) ; Merge into subfile...
. ; SIGDATA is the simplfied array. . K RAWDATA
. F S FMSIGNUM=$O(FMSIG(FMSIGNUM)) Q:FMSIGNUM="" D . N FMSIGNUM S FMSIGNUM="" ; Sigline number in fileman.
. . N DIRCNT S DIRCNT=$P(FMSIGNUM,",") . ; FMSIGNUM gets outputted as "IEN,RXIEN,".
. . N SIGDATA M SIGDATA=FMSIG(FMSIGNUM) . ; DIRCNT is the proper Sigline numer.
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components. . ; SIGDATA is the simplfied array.
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05. . F S FMSIGNUM=$O(FMSIG(FMSIGNUM)) Q:FMSIGNUM="" D
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$G(SIGDATA(8)) . . N DIRCNT S DIRCNT=$P(FMSIGNUM,",")
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$G(SIGDATA(.01)) . . N SIGDATA M SIGDATA=FMSIG(FMSIGNUM)
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=$G(SIGDATA(2)) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components.
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05.
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$G(SIGDATA(8))
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$G(SIGDATA(.01))
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$G(SIGDATA(6)) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=$G(SIGDATA(2))
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$G(SIGDATA(7)) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient
. . ; Invervals... again another call. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient
. . ; In the wisdom of the original programmers, the schedule is a free text field . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient
. . ; However, it gets translated by a call to the administration schedule file . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$G(SIGDATA(6))
. . ; to see if that schedule exists. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$G(SIGDATA(7))
. . ; That's the same thing I am going to do. . . ; Invervals... again another call.
. . ; Search B index of 51.1 (Admin Schedule) with schedule . . ; In the wisdom of the original programmers, the schedule is a free text field
. . ; First, remove "PRN" if it exists (don't ask, that's how the file . . ; However, it gets translated by a call to the administration schedule file
. . ; works; I wouldn't do it that way). . . ; to see if that schedule exists.
. . N SCHNOPRN S SCHNOPRN=$G(SIGDATA(7)) . . ; That's the same thing I am going to do.
. . I SCHNOPRN["PRN" S SCHNOPRN=$E(SCHNOPRN,1,$F(SCHNOPRN,"PRN")-5) . . ; Search B index of 51.1 (Admin Schedule) with schedule
. . ; Super call below: . . ; First, remove "PRN" if it exists (don't ask, that's how the file
. . ; 1=File 51.1 3=Field 2 (Frequency in Minutes) . . ; works; I wouldn't do it that way).
. . ; 4=Packed format, Exact Match 5=Lookup Value . . N SCHNOPRN S SCHNOPRN=$G(SIGDATA(7))
. . ; 6=# of entries to return 7=Index 10=Return Array . . I SCHNOPRN["PRN" S SCHNOPRN=$E(SCHNOPRN,1,$F(SCHNOPRN,"PRN")-5)
. . ; . . ; Super call below:
. . ; I do not account for the fact that two schedules can be . . ; 1=File 51.1 3=Field 2 (Frequency in Minutes)
. . ; spelled identically (ie duplicate entry). In that case, . . ; 4=Packed format, Exact Match 5=Lookup Value
. . ; I get the first. That's just a bad pharmacy pkg maintainer. . . ; 6=# of entries to return 7=Index 10=Return Array
. . N C0C515 . . ;
. . D FIND^DIC(51.1,,"@;2","PX",SCHNOPRN,1,"B",,,"C0C515") . . ; I do not account for the fact that two schedules can be
. . N INTERVAL S INTERVAL="" ; Default . . ; spelled identically (ie duplicate entry). In that case,
. . ; If there are entries found, get it . . ; I get the first. That's just a bad pharmacy pkg maintainer.
. . I +$G(C0C515("DILIST",0)) S INTERVAL=$P(C0C515("DILIST",1,0),U,2) . . N C0C515
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL . . D FIND^DIC(51.1,,"@;2","PX",SCHNOPRN,1,"B",,,"C0C515")
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute" . . N INTERVAL S INTERVAL="" ; Default
. . ; Duration is 10M minutes, 10H hours, 10D for Days . . ; If there are entries found, get it
. . ; 10W for weeks, 10L for months. I smell $Select . . I +$G(C0C515("DILIST",0)) S INTERVAL=$P(C0C515("DILIST",1,0),U,2)
. . ; But we don't need to do that if there isn't a duration . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL
. . I +$G(SIGDATA(4)) D . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute"
. . . N DURUNIT S DURUNIT=$E(SIGDATA(4),$L(SIGDATA(4))) ; get last char . . ; Duration is 10M minutes, 10H hours, 10D for Days
. . . N DURTXT S DURTXT=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"Days") . . ; 10W for weeks, 10L for months. I smell $Select
. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=+SIGDATA(4) . . ; But we don't need to do that if there isn't a duration
. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=DURTXT . . I +$G(SIGDATA(4)) D
. . E D . . . N DURUNIT S DURUNIT=$E(SIGDATA(4),$L(SIGDATA(4))) ; get last char
. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")="" . . . N DURTXT S DURTXT=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"Days")
. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")="" . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=+SIGDATA(4)
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$G(SIGDATA(4))["PRN" . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=DURTXT
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")="" ; when avail . . E D
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")="" . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=""
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")="" . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=""
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$G(SIGDATA(4))["PRN"
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")="" ; when avail
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")=""
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" ; not stored . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")=""
. . ; Another confusing line; I am pretty bad: . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")=""
. . ; If there is another entry in the FMSIG array (i.e. another line . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")=""
. . ; in the sig), set the direction count indicator. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")=""
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")="" ; Default . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" ; not stored
. . S:+$O(FMSIG(FMSIGNUM)) @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRCNT . . ; Another confusing line; I am pretty bad:
. . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$G(SIGDATA(5)) . . ; If there is another entry in the FMSIG array (i.e. another line
. ; . . ; in the sig), set the direction count indicator.
. ; --- END OF DIRECTIONS --- . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")="" ; Default
. ; . . S:+$O(FMSIG(FMSIGNUM)) @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRCNT
. ; Med instructions is a WP field, thus the acrobatics . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$G(SIGDATA(5))
. ; Notice buffer overflow protection set at 10,000 chars . ;
. ; -- 1. Med Patient Instructions . ; --- END OF DIRECTIONS ---
. N MEDPTIN1 S MEDPTIN1=$$GET1^DIQ(52,RXIEN,115,,"MEDPTIN1") . ;
. N MEDPTIN2,J S (MEDPTIN2,J)="" . ; Med instructions is a WP field, thus the acrobatics
. I $L(MEDPTIN1) F S J=$O(@MEDPTIN1@(J)) Q:J="" Q:$L(MEDPTIN2)>10000 S MEDPTIN2=MEDPTIN2_@MEDPTIN1@(J)_" " . ; Notice buffer overflow protection set at 10,000 chars
. S @MAP@("MEDPTINSTRUCTIONS")=MEDPTIN2 . ; -- 1. Med Patient Instructions
. K J . N MEDPTIN1 S MEDPTIN1=$$GET1^DIQ(52,RXIEN,115,,"MEDPTIN1")
. ; -- 2. Med Provider Instructions . N MEDPTIN2,J S (MEDPTIN2,J)=""
. N MEDPVIN1 S MEDPVIN1=$$GET1^DIQ(52,RXIEN,39,,"MEDPVIN1") . I $L(MEDPTIN1) F S J=$O(@MEDPTIN1@(J)) Q:J="" Q:$L(MEDPTIN2)>10000 S MEDPTIN2=MEDPTIN2_@MEDPTIN1@(J)_" "
. N MEDPVIN2,J S (MEDPVIN2,J)="" . S @MAP@("MEDPTINSTRUCTIONS")=MEDPTIN2
. I $L(MEDPVIN1) F S J=$O(@MEDPVIN1@(J)) Q:J="" Q:$L(MEDPVIN2)>10000 S MEDPVIN2=MEDPVIN2_@MEDPVIN1@(J)_" " . K J
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=MEDPVIN2 . ; -- 2. Med Provider Instructions
. ; . N MEDPVIN1 S MEDPVIN1=$$GET1^DIQ(52,RXIEN,39,,"MEDPVIN1")
. ; Remaining refills . N MEDPVIN2,J S (MEDPVIN2,J)=""
. S @MAP@("MEDRFNO")=$P(MEDS(MEDCNT),U,6) . I $L(MEDPVIN1) F S J=$O(@MEDPVIN1@(J)) Q:J="" Q:$L(MEDPVIN2)>10000 S MEDPVIN2=MEDPVIN2_@MEDPVIN1@(J)_" "
. ; ------ END OF MAPPING . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=MEDPVIN2
. ; . ;
. ; ------ BEGIN XML INSERTION . ; Remaining refills
. N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED")) . S @MAP@("MEDRFNO")=$P(MEDS(MEDCNT),U,6)
. K @RESULT . ; ------ END OF MAPPING
. D MAP^C0CXPATH(MINXML,MAP,RESULT) . ;
. ; D PARY^C0CXPATH(RESULT) . ; ------ BEGIN XML INSERTION
. ; MAPPING DIRECTIONS . N RESULT S RESULT=$NA(^TMP("C0CCCR",$J,"MAPPED"))
. N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE . K @RESULT
. N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT . D MAP^C0CXPATH(MINXML,MAP,RESULT)
. D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1) . ; D PARY^C0CXPATH(RESULT)
. D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions") . ; MAPPING DIRECTIONS
. ; N MDZ1,MDZNA . N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE
. N DIRCNT S DIRCNT="" . N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT
. I +$O(@MAP@("M","DIRECTIONS",DIRCNT)) D ; IF THERE ARE DIRCTIONS . D QUERY^C0CXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1)
. . F DIRCNT=$O(@MAP@("M","DIRECTIONS",DIRCNT)) D ; FOR EACH DIRECTION . D REPLACE^C0CXPATH(RESULT,"","//Medications/Medication/Directions")
. . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",DIRCNT)) . ; N MDZ1,MDZNA
. . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2) . N DIRCNT S DIRCNT=""
. . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication") . I +$O(@MAP@("M","DIRECTIONS",DIRCNT)) D ; IF THERE ARE DIRCTIONS
. D:MEDCNT=1 CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy . . F DIRCNT=$O(@MAP@("M","DIRECTIONS",DIRCNT)) D ; FOR EACH DIRECTION
. D:MEDCNT>1 INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML . . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",DIRCNT))
N MEDTMP,MEDI . . . D MAP^C0CXPATH(DIRXML1,MDZNA,DIRXML2)
D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS . . . D INSERT^C0CXPATH(RESULT,DIRXML2,"//Medications/Medication")
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ . D:MEDCNT=1 CP^C0CXPATH(RESULT,OUTXML) ; First one is a copy
. W "MEDICATION MISSING ",! . D:MEDCNT>1 INSINNER^C0CXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),! N MEDTMP,MEDI
Q D MISSING^C0CXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
; I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
GETRXN(NDC) ; Extrinsic Function; PUBLIC; NDC to RxNorm . W "MEDICATION MISSING ",!
;; Get RxNorm Concept Number for a Given NDC . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
; Q
S NDC=$TR(NDC,"-") ; Remove dashes ;
N RXNORM,C0CZRXN,DIERR GETRXN(NDC) ; Extrinsic Function; PUBLIC; NDC to RxNorm
D FIND^DIC(176.002,,"@;.01","PX",NDC,"*","NDC",,,"C0CZRXN","DIERR") ;; Get RxNorm Concept Number for a Given NDC
I $D(DIERR) D ^%ZTER BREAK ;
S RXNORM(0)=+C0CZRXN("DILIST",0) ; RxNorm(0) will be # of entries S NDC=$TR(NDC,"-") ; Remove dashes
N I S I=0 N RXNORM,C0CZRXN,DIERR
F S I=$O(C0CZRXN("DILIST",I)) Q:I="" S RXNORM(I)=$P(C0CZRXN("DILIST",I,0),U,2) D FIND^DIC(176.002,,"@;.01","PX",NDC,"*","NDC",,,"C0CZRXN","DIERR")
; At this point, RxNorm(0) is # of entries; RxNorm(1...) are the entries I $D(DIERR) D ^%ZTER BREAK
; If RxNorm(0) is 1, then we only have one entry, and that's it. S RXNORM(0)=+C0CZRXN("DILIST",0) ; RxNorm(0) will be # of entries
I RXNORM(0)=1 QUIT RXNORM(1) ; RETURN RXNORM(1) N I S I=0
; Otherwise, we need to find out which one is the semantic F S I=$O(C0CZRXN("DILIST",I)) Q:I="" S RXNORM(I)=$P(C0CZRXN("DILIST",I,0),U,2)
; clinical drug. I built an index on 176.001 (RxNorm Concepts) ; At this point, RxNorm(0) is # of entries; RxNorm(1...) are the entries
; for that purpose. ; If RxNorm(0) is 1, then we only have one entry, and that's it.
I RXNORM(0)>1 D I RXNORM(0)=1 QUIT RXNORM(1) ; RETURN RXNORM(1)
. S I=0 ; Otherwise, we need to find out which one is the semantic
. F S I=$O(RXNORM(I)) Q:I="" D Q:$G(RXNORM) ; clinical drug. I built an index on 176.001 (RxNorm Concepts)
. . N RXNIEN S RXNIEN=$$FIND1^DIC(176.001,,,RXNORM(I),"SCD") ; for that purpose.
. . I +$G(RXNIEN)=0 QUIT ; try the next entry... I RXNORM(0)>1 D
. . E S RXNORM=RXNORM(I) QUIT ; We found the right code . S I=0
QUIT +$G(RXNORM) ; RETURN RXNORM; if we couldn't find a clnical drug, return with 0 . F S I=$O(RXNORM(I)) Q:I="" D Q:$G(RXNORM)
. . N RXNIEN S RXNIEN=$$FIND1^DIC(176.001,,,RXNORM(I),"SCD")
. . I +$G(RXNIEN)=0 QUIT ; try the next entry...
. . E S RXNORM=RXNORM(I) QUIT ; We found the right code
QUIT +$G(RXNORM) ; RETURN RXNORM; if we couldn't find a clnical drug, return with 0

View File

@ -1,62 +1,62 @@
GPLPARMS ; CCDCCR/GPL - CCR/CCD PARAMETER PROCESSING ; 1/29/09 C0CPARMS ; CCDCCR/GPL - CCR/CCD PARAMETER PROCESSING ; 1/29/09
;;0.3;CCDCCR;nopatch;noreleasedate ;;0.3;CCDCCR;nopatch;noreleasedate
;Copyright 2008 WorldVistA. Licensed under the terms of the GNU ;Copyright 2008 WorldVistA. Licensed under the terms of the GNU
;General Public License See attached copy of the License. ;General Public License See attached copy of the License.
; ;
;This program is free software; you can redistribute it and/or modify ;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 ;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or ;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version. ;(at your option) any later version.
; ;
;This program is distributed in the hope that it will be useful, ;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of ;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details. ;GNU General Public License for more details.
; ;
;You should have received a copy of the GNU General Public License along ;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., ;with this program; if not, write to the Free Software Foundation, Inc.,
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
; ;
SET(INPARMS) ;INITIALIZE RUNTIME PARMS USING INPARMS TO OVERRIDE DEFAULTS SET(INPARMS) ;INITIALIZE RUNTIME PARMS USING INPARMS TO OVERRIDE DEFAULTS
; PARAMETERS ARE PASSED AS A STRING: "PARM1:VALUE1^PARM2:VALUE2^ETC" ; PARAMETERS ARE PASSED AS A STRING: "PARM1:VALUE1^PARM2:VALUE2^ETC"
; THE SAME FORMAT IS USED BY RPC AND COMMAND LINE ENTRY POINTS ; THE SAME FORMAT IS USED BY RPC AND COMMAND LINE ENTRY POINTS
; ;
N PTMP ; N PTMP ;
S C0CPARMS=$NA(^TMP("C0CPARMS",$J)) ;BASE FOR THIS RUN S C0CPARMS=$NA(^TMP("C0CPARMS",$J)) ;BASE FOR THIS RUN
;K @C0CPARMS ;START WITH EMPTY PARMS; MAY NOT WANT TO DO THIS KILL ;K @C0CPARMS ;START WITH EMPTY PARMS; MAY NOT WANT TO DO THIS KILL
I $G(INPARMS)'="" D ; OVERRIDES PROVIDED I $G(INPARMS)'="" D ; OVERRIDES PROVIDED
. N C0CI S C0CI="" . N C0CI S C0CI=""
. N C0CN S C0CN=1 . N C0CN S C0CN=1
. F S C0CI=$P(INPARMS,"^",C0CN) Q:C0CI="" D ; . F S C0CI=$P(INPARMS,"^",C0CN) Q:C0CI="" D ;
. . S C0CN=C0CN+1 ;NEXT PARM . . S C0CN=C0CN+1 ;NEXT PARM
. . N C1,C2 . . N C1,C2
. . S C1=$P(C0CI,":",1) ; PARAMETER . . S C1=$P(C0CI,":",1) ; PARAMETER
. . S C2=$P(C0CI,":",2) ; VALUE . . S C2=$P(C0CI,":",2) ; VALUE
. . I C2="" S C2=1 . . I C2="" S C2=1
. . S @C0CPARMS@(C1)=C2 . . S @C0CPARMS@(C1)=C2
. I C0CN=1 S @C0CPARMS@($P(INPARMS,":",1))=$P(C0CI,":",2) ; ONLY ONE . I C0CN=1 S @C0CPARMS@($P(INPARMS,":",1))=$P(C0CI,":",2) ; ONLY ONE
; THIS IS WHERE WE WILL INSERT CALLS TO THE PARAMETER FILE FOR DEFAULTS ; THIS IS WHERE WE WILL INSERT CALLS TO THE PARAMETER FILE FOR DEFAULTS
; IF THEY FAIL, THE FOLLOWING WILL BE HARDCODED DEFAULTS ; IF THEY FAIL, THE FOLLOWING WILL BE HARDCODED DEFAULTS
I '$D(@C0CPARMS@("LABLIMIT")) S @C0CPARMS@("LABLIMIT")="T-360" ;ONE YR WORTH I '$D(@C0CPARMS@("LABLIMIT")) S @C0CPARMS@("LABLIMIT")="T-360" ;ONE YR WORTH
I '$D(@C0CPARMS@("LABSTART")) S @C0CPARMS@("LABSTART")="T" ;TODAY I '$D(@C0CPARMS@("LABSTART")) S @C0CPARMS@("LABSTART")="T" ;TODAY
I '$D(@C0CPARMS@("VITLIMIT")) S @C0CPARMS@("VITLIMIT")="T-360" ;ONE YR VITALS I '$D(@C0CPARMS@("VITLIMIT")) S @C0CPARMS@("VITLIMIT")="T-360" ;ONE YR VITALS
I '$D(@C0CPARMS@("VITSTART")) S @C0CPARMS@("VITSTART")="T" ;TODAY I '$D(@C0CPARMS@("VITSTART")) S @C0CPARMS@("VITSTART")="T" ;TODAY
I '$D(@C0CPARMS@("MEDSTART")) S @C0CPARMS@("MEDSTART")="T" ; TODAY I '$D(@C0CPARMS@("MEDSTART")) S @C0CPARMS@("MEDSTART")="T" ; TODAY
I '$D(@C0CPARMS@("MEDSLIMIT")) S @C0CPARMS@("MEDLIMIT")="T-360" ; ONE YR MEDS I '$D(@C0CPARMS@("MEDSLIMIT")) S @C0CPARMS@("MEDLIMIT")="T-360" ; ONE YR MEDS
I '$D(@C0CPARMS@("MEDACTIVE")) S @C0CPARMS@("MEDACTIVE")=1 ; YES I '$D(@C0CPARMS@("MEDACTIVE")) S @C0CPARMS@("MEDACTIVE")=1 ; YES
I '$D(@C0CPARMS@("MEDPENDING")) S @C0CPARMS@("MEDPENDING")=0 ; NO I '$D(@C0CPARMS@("MEDPENDING")) S @C0CPARMS@("MEDPENDING")=0 ; NO
I '$D(@C0CPARMS@("MEDALL")) S @C0CPARMS@("MEDALL")=0 ; NON-PENDING NON-ACTIVE I '$D(@C0CPARMS@("MEDALL")) S @C0CPARMS@("MEDALL")=0 ; NON-PENDING NON-ACTIVE
Q Q
; ;
CHECK ; CHECK TO SEE IF PARMS ARE PRESENT, ELSE RUN SET CHECK ; CHECK TO SEE IF PARMS ARE PRESENT, ELSE RUN SET
; ;
I '$D(C0CPARMS) S C0CPARMS=$NA(^TMP("C0CPARMS",$J)) ;SHOULDN'T HAPPEN I '$D(C0CPARMS) S C0CPARMS=$NA(^TMP("C0CPARMS",$J)) ;SHOULDN'T HAPPEN
I '$D(@C0CPARMS) D SET("SETWITHCHECK:1") I '$D(@C0CPARMS) D SET("SETWITHCHECK:1")
Q Q
; ;
GET(WHICHP) ;EXTRINSIC TO RETURN THE VALUE OF PARAMETER WHICHP GET(WHICHP) ;EXTRINSIC TO RETURN THE VALUE OF PARAMETER WHICHP
; ;
D CHECK ; SHOULDN'T HAPPEN BUT TO BE SAFE D CHECK ; SHOULDN'T HAPPEN BUT TO BE SAFE
N GTMP N GTMP
Q $G(@C0CPARMS@(WHICHP)) ;PULL THE PARM FROM THE TABLE Q $G(@C0CPARMS@(WHICHP)) ;PULL THE PARM FROM THE TABLE
; ;