Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSOERXOI

PSOERXOI.m

Go to the documentation of this file.
PSOERXOI ;ALB/BWF - eRx parsing Utilities ; 11/14/2019 3:46pm
 ;;7.0;OUTPATIENT PHARMACY;**581,746**;DEC 1997;Build 106
 ;
 Q
SIG(GL,CNT,ERXIEN,MIEN) ;
 N SIGTEXT,SNOMED,FMTVER,SIGCFT,SIGDAT,F,IENS,SIGL
 S F=52.49311
 S IENS=MIEN_","_ERXIEN_","
 D GETS^DIQ(F,IENS,"9.1;9.2;15","E","SIGDAT")
 S SNOMED=$G(SIGDAT(F,IENS,9.1,"E"))
 S FMTVER=$G(SIGDAT(F,IENS,9.2,"E"))
 S SIGCFT=$G(SIGDAT(F,IENS,15,"E"))
 D C S @GL@(CNT,0)="<Sig>"
 S SIGTEXT=""
 S SIGL=0 F  S SIGL=$O(^PS(52.49,ERXIEN,311,MIEN,8,SIGL)) Q:'SIGL  D
 .S SIGTEXT=SIGTEXT_$G(^PS(52.49,ERXIEN,311,MIEN,8,SIGL,0))_" "
 S $E(SIGTEXT,$L(SIGTEXT))=""
 D BL(GL,.CNT,"SigText",SIGTEXT)
 D C S @GL@(CNT,0)="<CodeSystem>"
 D BL(GL,.CNT,"SNOMEDVersion",SNOMED),BL(GL,.CNT,"FMTVersion",FMTVER)
 D C S @GL@(CNT,0)="</CodeSystem>"
 D MEDINST^PSOERXOJ(GL,.CNT,ERXIEN,MIEN)
 D SIGI4USE(GL,.CNT,ERXIEN,MIEN)
 D SIGMDR(GL,.CNT,ERXIEN,MIEN)
 D BL(GL,.CNT,"ClarifyingFreeText",SIGCFT)
 D C S @GL@(CNT,0)="</Sig>"
 Q
 ; sig level maximum dose restriction
SIGMDR(GL,CNT,ERXIEN,MIEN) ;
 N MDRIEN,MDRIENS,MDRV,MDRDAT,F,MDRV1,RUC,RUQ,RUT,DVAL,DUC,DUQ,DUT,RFC,RFQ,RFT,CFTEXT
 S F=52.4931114
 I '$O(^PS(52.49,ERXIEN,311,MIEN,14,0)) Q
 S MDRIEN=0 F  S MDRIEN=$O(^PS(52.49,ERXIEN,311,MIEN,14,MDRIEN)) Q:'MDRIEN  D
 .K MDRDAT
 .S MDRIENS=MDRIEN_","_MIEN_","_ERXIEN_","
 .D GETS^DIQ(F,MDRIENS,"**","E","MDRDAT")
 .S MDRV1=$G(MDRDAT(F,MDRIENS,1,"E")),RUC=$G(MDRDAT(F,MDRIENS,2,"E")),RUQ=$G(MDRDAT(F,MDRIENS,3,"E")),RUT=$G(MDRDAT(F,MDRIENS,4,"E"))
 .S DVAL=$G(MDRDAT(F,MDRIENS,5,"E")),DUC=$G(MDRDAT(F,MDRIENS,6,"E")),DUQ=$G(MDRDAT(F,MDRIENS,7,"E")),DUT=$G(MDRDAT(F,MDRIENS,8,"E"))
 .S RFC=$G(MDRDAT(F,MDRIENS,9,"E")),RFQ=$G(MDRDAT(F,MDRIENS,10,"E")),RFT=$G(MDRDAT(F,MDRIENS,11,"E"))
 .S CFTEXT=$G(MDRDAT(F,MDRIENS,12,"E"))
 .D C S @GL@(CNT,0)="<MaximumDoseRestriction>"
 .D BL(.GL,.CNT,"MaximumDoseRestrictionNumericValue",MDRV1)
 .D SIGTYPE^PSOERXOU(.GL,.CNT,"MaximumDoseRestrictionForm",RFT,RFQ,RFC)
 .D SIGTYPE^PSOERXOU(.GL,.CNT,"MaximumDoseRestrictionUnits",RUT,RUQ,RUC)
 .D BL(.GL,.CNT,"MaximumDoseRestrictionDurationValue",DVAL)
 .D SIGTYPE^PSOERXOU(.GL,.CNT,"MaximumDoseRestrictionDurationUnit",DUT,DUQ,DUC)
 .D BL(.GL,.CNT,"MaximumDoseRestrictionClarifyingFreeText",CFTEXT)
 .D C S @GL@(CNT,0)="</MaximumDoseRestriction>"
 Q
 ; indication for use at the sig level (medication prescribed)
SIGI4USE(GL,CNT,ERXIEN,MIEN) ;
 N F,IFUIEN,IFUIENS,IFUDAT,IPC,IPQ,IPT,IC,IQ,IT,IVC1,IVQ1,IVT1,IVM,IVC2,IVQ2,IVT2,IVUC,IVUQ,IVUT
 N IUOMC,IUOMQ,IUOMT
 S F=52.4931113
 ; dont build anything if the subscript is missing
 Q:'$O(^PS(52.49,ERXIEN,311,MIEN,13,0))
 S IFUIEN=0,IFUIEN=$O(^PS(52.49,ERXIEN,311,MIEN,13,IFUIEN)) Q:'IFUIEN  D
 .K IFUDAT
 .S IFUIENS=IFUIEN_","_MIEN_","_ERXIEN_","
 .D C S @GL@(CNT,0)="<IndicationForUse>"
 .D GETS^DIQ(F,IFUIENS,"**","E","IFUDAT")
 .S IPC=$G(IFUDAT(F,IFUIENS,1,"E")),IPQ=$G(IFUDAT(F,IFUIENS,2,"E")),IPT=$G(IFUDAT(F,IFUIENS,3,"E"))
 .S IC=$G(IFUDAT(F,IFUIENS,4,"E")),IQ=$G(IFUDAT(F,IFUIENS,5,"E")),IT=$G(IFUDAT(F,IFUIENS,6,"E"))
 .S IVC1=$G(IFUDAT(F,IFUIENS,7,"E")),IVQ1=$G(IFUDAT(F,IFUIENS,8,"E")),IVT1=$G(IFUDAT(F,IFUIENS,9,"E"))
 .S IVM=$G(IFUDAT(F,IFUIENS,10,"E"))
 .S IVC2=$G(IFUDAT(F,IFUIENS,11,"E")),IVQ2=$G(IFUDAT(F,IFUIENS,12,"E")),IVT2=$G(IFUDAT(F,IFUIENS,13,"E"))
 .S IVUC=$G(IFUDAT(F,IFUIENS,14,"E")),IVUQ=$G(IFUDAT(F,IFUIENS,15,"E")),IVUT=$G(IFUDAT(F,IFUIENS,16,"E"))
 .S IUOMC=$G(IFUDAT(F,IFUIENS,17,"E")),IUOMQ=$G(IFUDAT(F,IFUIENS,18,"E")),IUOMT=$G(IFUDAT(F,IFUIENS,19,"E"))
 .D SIGTYPE^PSOERXOU(GL,.CNT,"IndicationPrescursor",IPT,IPQ,IPC)
 .D SIGTYPE^PSOERXOU(GL,.CNT,"Indication",IT,IQ,IC)
 .D SIGTYPE^PSOERXOU(GL,.CNT,"IndicationValue",IVT1,IVQ1,IVC1)
 .I $L(IVM) D BL(GL,.CNT,"IndicationVariableModifier",IVM)
 .D SIGTYPE^PSOERXOU(GL,.CNT,"IndicationValue",IVT2,IVQ2,IVC2)
 .D SIGTYPE^PSOERXOU(GL,.CNT,"IndicationValueUnit",IVUT,IVUQ,IVUC)
 .D SIGTYPE^PSOERXOU(GL,.CNT,"IndicationValueUnitOfMeasure",IUOMT,IUOMQ,IUOMC)
 D C S @GL@(CNT,0)="</IndicationForUse>"
 Q
BL(GBL,CNT,TAG,VAR) ;
 Q:VAR=""
 D C S @GBL@(CNT,0)="<"_TAG_">"_$$SYMENC^MXMLUTL(VAR)_"</"_TAG_">"
 Q
C ;
 S CNT=$G(CNT)+1
 Q