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

PSOERXOE.m

Go to the documentation of this file.
PSOERXOE ;ALB/BWF - eRx parsing Utilities ; 11/14/2019 3:46pm
 ;;7.0;OUTPATIENT PHARMACY;**581**;DEC 1997;Build 126
 ;
 Q
 ;
 ; GBL - GLOBAL WHERE DATA IS STORED
 ; IEN - IEN TO 52.49
 ; PTYPE - person type (P-Pharmacist, PR - Prescriber, S - Supervisor, FU - FollowUp Prescriber 
PERSON(GBL,CNT,PSOSITE,IEN,PTYPE) ;
 N F,DEAN,NPI,SPEC,CLINIC,LNAME,FNAME,MNAME,SUFF,PREF,ADDL1,ADDL2,CITY,STATE,ZIP,CNTRY,ALNAME,AFNAME,AMNAME,ASUFF,APREF
 N PSDAT,CLOOP,CNUM,CQUAL,ILOOP,ITYP,IVAL,PIEN,PIENS,VNV,BNAME,CERT2P,DATA2000,DEA,FAFNAME
 N FALNAME,FAMNAME,FAPREF,FASUFF,FFN,FLN,FMN,FNAME,FPRE,FSUF,HIN,IENS,MCAID,MCARE,MDEF,PTAG
 N PDEA,PFID,PHIN,PMCAID,PMCARE,PMDEF,PNCPDP,PNPI,PPOS,PREMS,PSTLN,PUPIN,REMS,SGBL,SSN,STATECS
 N STATCS,STLN,UPIN
 S F=52.48,IENS=IEN_","
 I PTYPE="P" S PIEN=$$GET1^DIQ(52.49,IEN,2.2,"I")
 I PTYPE="PR" S PIEN=$$GET1^DIQ(52.49,IEN,2.1,"I")
 I PTYPE="S" S PIEN=$$GET1^DIQ(52.49,IEN,2.6,"I")
 I PTYPE="FU" S PIEN=$$GET1^DIQ(52.49,IEN,307.1,"I")
 Q:'PIEN
 S PIENS=PIEN_","
 D GETS^DIQ(F,PIENS,"**","IE","PSDAT")
 D CONVXML^PSOERXX1("PSDAT")
 S DEAN=$G(PSDAT(F,PIENS,1.6,"E"))
 S NPI=$G(PSDAT(F,PIENS,1.5,"E"))
 S PTAG=$S(PTYPE="P":"Pharmacist",PTYPE="PR":"Prescriber",PTYPE="S":"Supervisor",PTYPE="FP":"FolloupPrescriber",1:"")
 Q:PTAG=""
 S SPEC=$G(PSDAT(F,PIENS,1.2,"E"))
 S CLINIC=$G(PSDAT(F,PIENS,2.1,"E"))
 S ADDL1=$G(PSDAT(F,PIENS,4.1,"E"))
 S ADDL2=$G(PSDAT(F,PIENS,4.2,"E"))
 S CITY=$G(PSDAT(F,PIENS,4.3,"E"))
 S STATE=$G(PSDAT(F,PIENS,4.4,"I"))
 S ZIP=$G(PSDAT(F,PIENS,4.5,"E"))
 S CNTRY=$G(PSDAT(F,PIENS,2.2,"E"))
 S VNV=$G(PSDAT(F,PIENS,19.1,"I")),VNV=$S(VNV:"Veterinarian",1:"NonVeterinarian")
 D C S @GBL@(CNT,0)="<"_PTAG_">"
 D C S @GBL@(CNT,0)="<"_VNV_">"
 ; identification
 S STLN=$G(PSDAT(F,PIENS,14.1,"E")),MCARE=$G(PSDAT(F,PIENS,14.2,"E")),MCAID=$G(PSDAT(F,PIENS,14.3,"E")),UPIN=$G(PSDAT(F,PIENS,14.4,"E"))
 S DEA=$G(PSDAT(F,PIENS,14.5,"E")),HIN=$G(PSDAT(F,PIENS,14.6,"E")),SSN=$G(PSDAT(F,PIENS,14.7,"E"))
 S NPI=$G(PSDAT(F,PIENS,15.1,"E")),CERT2P=$G(PSDAT(F,PIENS,15.2,"E")),DATA2000=$G(PSDAT(F,PIENS,15.3,"E"))
 S MDEF=$G(PSDAT(F,PIENS,15.4,"E")),REMS=$G(PSDAT(F,PIENS,15.5,"E")),STATECS=$G(PSDAT(F,PIENS,15.6,"E"))
 D C S @GBL@(CNT,0)="<Identification>"
 D BL(GBL,.CNT,"StateLicenseNumber",STLN),BL(GBL,.CNT,"MedicareNumber",MCARE),BL(GBL,.CNT,"MedicaidNumber",MCAID)
 D BL(GBL,.CNT,"UPIN",UPIN),BL(GBL,.CNT,"DEANumber",DEA),BL(GBL,.CNT,"HIN",HIN)
 D BL(GBL,.CNT,"SocialSecurityNumber",SSN),BL(GBL,.CNT,"NPI",NPI),BL(GBL,.CNT,"CertificateToPrescribe",CERT2P)
 D BL(GBL,.CNT,"Data2000WaiverID",DATA2000),BL(GBL,.CNT,"MutuallyDefined",MDEF),BL(GBL,.CNT,"REMSHealthcareProviderEnrollmentID",REMS)
 D BL(GBL,.CNT,"StateControlSubstanceNumber",STATECS)
 D C S @GBL@(CNT,0)="</Identification>"
 I $L(SPEC) D C S @GBL@(CNT,0)="<Specialty>"_SPEC_"</Specialty>"
 ; Practice location fields
 S PNCPDP=$G(PSDAT(F,PIENS,17.1,"E")),PSTLN=$G(PSDAT(F,PIENS,17.2,"E")),PMCARE=$G(PSDAT(F,PIENS,17.3,"E")),PMCAID=$G(PSDAT(F,PIENS,17.4,"E"))
 S PUPIN=$G(PSDAT(F,PIENS,17.5,"E")),PFID=$G(PSDAT(F,PIENS,17.6,"E"))
 S PDEA=$G(PSDAT(F,PIENS,18.1,"E")),PHIN=$G(PSDAT(F,PIENS,18.2,"E")),PNPI=$G(PSDAT(F,PIENS,18.3,"E")),PMDEF=$G(PSDAT(F,PIENS,18.4,"E"))
 S PREMS=$G(PSDAT(F,PIENS,18.5,"E"))
 S BNAME=$G(PSDAT(F,PIENS,18.6,"E"))
 ; practice location segment
 D C S @GBL@(CNT,0)="<PracticeLocation>"
 D C S @GBL@(CNT,0)="<Identification>"
 D BL(GBL,.CNT,"NCPDPID",PNCPDP),BL(GBL,.CNT,"StateLicenseNumber",PSTLN),BL(GBL,.CNT,"MedicareNumber",PMCARE),BL(GBL,.CNT,"MedicaidNumber",PMCAID)
 D BL(GBL,.CNT,"UPIN",PUPIN),BL(GBL,.CNT,"FacilityID",PFID),BL(GBL,.CNT,"DEANumber",PDEA),BL(GBL,.CNT,"HIN",PHIN)
 D BL(GBL,.CNT,"NPI",PNPI),BL(GBL,.CNT,"MutuallyDefined",PMDEF),BL(GBL,.CNT,"REMSHealthcareSettingEnrollmentID",PREMS)
 D C S @GBL@(CNT,0)="</Identification>"
 D BL(GBL,.CNT,"BusinessName",BNAME)
 D C S @GBL@(CNT,0)="</PracticeLocation>"
 ; name
 S LNAME=$G(PSDAT(F,PIENS,.02,"E")),FNAME=$G(PSDAT(F,PIENS,.03,"E")),MNAME=$G(PSDAT(F,PIENS,.04,"E"))
 S SUFF=$G(PSDAT(F,PIENS,.05,"E")),PREF=$G(PSDAT(F,PIENS,.06,"E"))
 D ONAME^PSOERXOU(GBL,.CNT,"Name",LNAME,FNAME,MNAME,SUFF,PREF)
 ; former name
 S FLN=$G(PSDAT(F,PIENS,2.4,"E")),FFN=$G(PSDAT(F,PIENS,2.5,"E")),FMN=$G(PSDAT(F,PIENS,2.6,"E"))
 S FSUF=$G(PSDAT(F,PIENS,2.7,"E")),FPRE=$G(PSDAT(F,PIENS,2.8,"E"))
 D ONAME^PSOERXOU(GBL,.CNT,"FormerName",FLN,FFN,FMN,FSUF,FPRE)
 D OADD^PSOERXOU(GBL,.CNT,ADDL1,ADDL2,CITY,STATE,ZIP,CNTRY)
 ; agent name
 S ALNAME=$G(PSDAT(F,PIENS,5.1,"E")),AFNAME=$G(PSDAT(F,PIENS,5.2,"E")),AMNAME=$G(PSDAT(F,PIENS,5.3,"E"))
 S ASUFF=$G(PSDAT(F,PIENS,5.4,"E")),APREF=$G(PSDAT(F,PIENS,5.5,"E"))
 ; agent former name
 S FALNAME=$G(PSDAT(F,PIENS,5.1,"E")),FAFNAME=$G(PSDAT(F,PIENS,5.2,"E")),FAMNAME=$G(PSDAT(F,PIENS,5.3,"E"))
 S FASUFF=$G(PSDAT(F,PIENS,5.4,"E")),FAPREF=$G(PSDAT(F,PIENS,5.5,"E"))
 I $L(ALNAME) D
 .D C S @GBL@(CNT,0)="<PresriberAgent>"
 .D ONAME^PSOERXOU(GBL,.CNT,"Name",ALNAME,AFNAME,AMNAME,ASUFF,APREF)
 .I $L(FALNAME) D ONAME^PSOERXOU(GBL,.CNT,"FormerName",FALNAME,FAFNAME,FAMNAME,FASUFF,FAPREF)
 .D C S @GBL@(CNT,0)="</PresriberAgent>"
 S SGBL=$NA(^PS(52.48,PIEN,11))
 D OCOMM^PSOERXOU(GBL,SGBL,.CNT,PIENS,52.4811,52.48,12,PIENS)
 ; prescriber Place of service
 S PPOS=$G(PSDAT(F,PIENS,2.3,"E"))
 D BL(GBL,.CNT,"PrescriberPlaceOfService",PPOS)
 D C S @GBL@(CNT,0)="</"_VNV_">"
 D C S @GBL@(CNT,0)="</"_PTAG_">"
 Q
 ; GBL - GLOBAL WHERE DATA IS STORED
 ; IEN - IEN TO 52.49
PRORENRQ(GBL,CNT,IEN) ; Set up Prohibit Renewal Request
 N F,PROHIBIT
 S F=52.49
 S PROHIBIT=$$GET1^DIQ(52.49,IEN,301.3,"I")
 D BL(GBL,.CNT,"ProhibitRenewalRequest",PROHIBIT)
 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