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

PSOERXOC.m

Go to the documentation of this file.
PSOERXOC ;ALB/BWF - eRx parsing Utilities ; 11/14/2019 3:46pm
 ;;7.0;OUTPATIENT PHARMACY;**581**;DEC 1997;Build 126
 ;
 Q
PATIENT(GBL,CNT,PSOSITE,IEN) ;
 N F,PATREL,LNAME,FNAME,MNAME,SUFF,PREF,GENDER,DOB,ADDL1,ADDL2,CITY,STATE,ZIP,PLQ,CUNIT,BED,ROOM,PSDAT,ILOOP
 N ITYP,IVAL,CLOOP,CNUM,CQUAL,PIEN,PIENS,PSSN,LANGNC,GESTAGE,HOSPIND,ACLN,ACFN,ACMN,ACSUFF,ACPREF,ACRELAT,ACFLN
 N ACFFN,ACFMN,ACFSUFF,ACFPREF,ACADL1,ACADL2,ACCITY,ACSTATE,ACPOSTAL,ACCC,DIRADD,ALDIRADD,MEDICARE,MEDICAID,MEDICAL,ACCNUM,MUTDEF,REMS
 N ASGBL,CC,FOFN,FOLN,FOMN,FOPREF,FOSUFF,SGBL
 S F=52.46
 S PIEN=$$GET1^DIQ(52.49,IEN,.04,"I") Q:'PIEN
 S PIENS=PIEN_","
 D GETS^DIQ(F,PIENS,"**","IE","PSDAT")
 D CONVXML^PSOERXX1("PSDAT")
 S PATREL=$G(PSDAT(F,PIENS,1.7,"I"))
 S LNAME=$G(PSDAT(F,PIENS,.02,"E"))
 S FNAME=$G(PSDAT(F,PIENS,.03,"E"))
 S MNAME=$G(PSDAT(F,PIENS,.04,"E"))
 S SUFF=$G(PSDAT(F,PIENS,.05,"E"))
 S PREF=$G(PSDAT(F,PIENS,.06,"E"))
 S GENDER=$G(PSDAT(F,PIENS,.07,"I"))
 S DOB=$G(PSDAT(F,PIENS,.08,"I")) I $G(DOB) S DOB=$P($$EXTIME^PSOERXO1(DOB),"T")
 S ADDL1=$G(PSDAT(F,PIENS,3.1,"E"))
 S ADDL2=$G(PSDAT(F,PIENS,3.2,"E"))
 S CITY=$G(PSDAT(F,PIENS,3.3,"E"))
 S STATE=$G(PSDAT(F,PIENS,3.4,"I"))
 S ZIP=$G(PSDAT(F,PIENS,3.5,"E"))
 S CC=$G(PSDAT(F,PIENS,1.6,"E"))
 S PSSN=$G(PSDAT(F,PIENS,18.2,"E"))
 ; FUTURE ENHANCEMENT, GRAB CUNIT/BED/ROOM FROM CORRECT LOCATIONS. THIS LOGIC IS NOT ACTIVE WITH VERSION 2 
 S CUNIT=$G(PSDAT(F,PIENS,8.1,"E")) ; 8.1
 S BED=$G(PSDAT(F,PIENS,8.2,"E")) ; 8.3
 S ROOM=$G(PSDAT(F,PIENS,8.3,"E")) ; 8.2
 ;
 ;start grabbing 2017 variables
 ;
 S FOLN=$G(PSDAT(F,PIENS,7.1,"E"))
 S FOFN=$G(PSDAT(F,PIENS,7.2,"E"))
 S FOMN=$G(PSDAT(F,PIENS,7.3,"E"))
 S FOSUFF=$G(PSDAT(F,PIENS,7.4,"E"))
 S FOPREF=$G(PSDAT(F,PIENS,7.5,"E"))
 S LANGNC=$G(PSDAT(F,PIENS,8.4,"E"))
 S GESTAGE=$G(PSDAT(F,PIENS,8.5,"E"))
 S HOSPIND=$G(PSDAT(F,PIENS,8.6,"I"))
 S ACLN=$G(PSDAT(F,PIENS,9.1,"E"))
 S ACFN=$G(PSDAT(F,PIENS,9.2,"E"))
 S ACMN=$G(PSDAT(F,PIENS,9.3,"E"))
 S ACSUFF=$G(PSDAT(F,PIENS,9.4,"E"))
 S ACPREF=$G(PSDAT(F,PIENS,9.5,"E"))
 S ACRELAT=$G(PSDAT(F,PIENS,9.6,"I")),ACRELAT=$$GET1^DIQ(52.45,ACRELAT,.01,"E")
 S ACFLN=$G(PSDAT(F,PIENS,10.1,"E"))
 S ACFFN=$G(PSDAT(F,PIENS,10.2,"E"))
 S ACFMN=$G(PSDAT(F,PIENS,10.3,"E"))
 S ACFSUFF=$G(PSDAT(F,PIENS,10.4,"E"))
 S ACFPREF=$G(PSDAT(F,PIENS,10.5,"E"))
 S ACADL1=$G(PSDAT(F,PIENS,11.1,"E"))
 S ACADL2=$G(PSDAT(F,PIENS,11.2,"E"))
 S ACCITY=$G(PSDAT(F,PIENS,11.3,"E"))
 S ACSTATE=$G(PSDAT(F,PIENS,11.4,"I"))
 S ACPOSTAL=$G(PSDAT(F,PIENS,11.5,"E"))
 S ACCC=$G(PSDAT(F,PIENS,11.6,"E"))
 ;alternate communication
 S ASGBL=$NA(^PS(52.46,IEN,15))
 S ALDIRADD=$G(PSDAT(F,PIENS,16,"E"))
 S MEDICARE=$G(PSDAT(F,PIENS,17.1,"E"))
 S MEDICAID=$G(PSDAT(F,PIENS,17.2,"E"))
 S MEDICAL=$G(PSDAT(F,PIENS,17.3,"E"))
 S ACCNUM=$G(PSDAT(F,PIENS,18.1,"E"))
 S MUTDEF=$G(PSDAT(F,PIENS,18.3,"E"))
 S REMS=$G(PSDAT(F,PIENS,18.4,"E"))
 ;end 2017 variables
 ;
 ;new outbound building - 12/9/19
 ;
 D C S @GBL@(CNT,0)="<Patient>"
 D C S @GBL@(CNT,0)="<HumanPatient>"
 I $L(MEDICARE_MEDICAID_MEDICAL_ACCNUM_PSSN_MUTDEF_REMS) D
 .D C S @GBL@(CNT,0)="<Identification>"
 .D BL(GBL,.CNT,"MedicareNumber",MEDICARE)
 .D BL(GBL,.CNT,"MedicaidNumber",MEDICAID)
 .D BL(GBL,.CNT,"MedicalRecordIdentificationNumberEHR",MEDICAL)
 .D BL(GBL,.CNT,"PatientAccountNumber",ACCNUM)
 .D BL(GBL,.CNT,"SocialSecurity",PSSN)
 .D BL(GBL,.CNT,"MutuallyDefined",MUTDEF)
 .D BL(GBL,.CNT,"REMSPatientID",REMS)
 .D C S @GBL@(CNT,0)="</Identification>"
 D ONAME^PSOERXOU(GBL,.CNT,"Name",LNAME,FNAME,MNAME,SUFF,PREF)
 I $L(FOLN) D
 .D ONAME^PSOERXOU(GBL,.CNT,"FormerName",FOLN,FOFN,FOMN,FOSUFF,FOPREF)
 D BL(GBL,.CNT,"Gender",GENDER)
 D C S @GBL@(CNT,0)="<DateOfBirth>"
 D BL(GBL,.CNT,"Date",DOB)
 D C S @GBL@(CNT,0)="</DateOfBirth>"
 D OADD^PSOERXOU(GBL,.CNT,ADDL1,ADDL2,CITY,STATE,ZIP,CC)
 S SGBL=$NA(^PS(52.46,PIEN,13))
 D OCOMM^PSOERXOU(GBL,SGBL,.CNT,PIEN_",",52.4613,52.46,14,PIEN_",")
 I $L(CUNIT_BED_ROOM) D
 .D C S @GBL@(CNT,0)="<PatientLocation>"
 .D BL(GBL,.CNT,"FacilityUnit",CUNIT)
 .D BL(GBL,.CNT,"BED",BED)
 .D BL(GBL,.CNT,"Room",ROOM)
 .D C S @GBL@(CNT,0)="</PatientLocation>"
 .D BL(GBL,.CNT,"LanguageNameCode",LANGNC)
 D SUBSTNCE(PIEN,52.4619,GBL)
 I $L(ACLN) D
 .D C S @GBL@(CNT,0)="<AlternateContact>"
 .D ONAME^PSOERXOU(GBL,.CNT,"Name",ACLN,ACFN,ACMN,ACSUFF,ACPREF)
 .I $L(ACFLN) D
 ..D ONAME^PSOERXOU(GBL,.CNT,"FormerName",ACFLN,ACFFN,ACFMN,ACFPREF,ACFSUFF)
 .D OADD^PSOERXOU(GBL,.CNT,ACADL1,ACADL2,ACCITY,ACSTATE,ACPOSTAL,ACCC)
 .S SGBL=$NA(^PS(52.46,PIEN,15))
 .D OCOMM^PSOERXOU(GBL,SGBL,.CNT,PIEN_",",52.4615,52.46,16,PIEN_",")
 .D BL(GBL,.CNT,"AlternateContactRelationship",ACRELAT)
 .D C S @GBL@(CNT,0)="</AlternateContact>"
 .D BL(GBL,.CNT,"GestationalAge",GESTAGE)
 .D BL(GBL,.CNT,"HospiceIndicator",HOSPIND)
 ;end new outbound building
 D C S @GBL@(CNT,0)="</HumanPatient>"
 D C S @GBL@(CNT,0)="</Patient>"
 Q
SUBSTNCE(PIEN,SFILE,GBL) ; patient substance (52.4619)
 N SFIEN,SUBIENS,TYPETEXT,TYPEQUAL,TYPECODE,LEVTEXT
 N LEVQUAL,LEVCODE,ROATEXT,ROAQUAL,ROACODE,SUBDAT
 S SFIEN=0,IEN=5531,SFILE=52.4619
 Q:'$O(^PS(52.46,PIEN,19,0))
 F  S SFIEN=$O(^PS(52.46,PIEN,19,SFIEN)) Q:'SFIEN  D
 .S SUBIENS=SFIEN_","_PIEN_","
 .D GETS^DIQ(52.4619,SUBIENS,"**","E","SUBDAT")
 .S TYPETEXT=$G(SUBDAT(SFILE,SUBIENS,1,"E"))
 .S TYPEQUAL=$G(SUBDAT(SFILE,SUBIENS,2,"E"))
 .S TYPECODE=$G(SUBDAT(SFILE,SUBIENS,3,"E"))
 .S LEVTEXT=$G(SUBDAT(SFILE,SUBIENS,4,"E"))
 .S LEVQUAL=$G(SUBDAT(SFILE,SUBIENS,5,"E"))
 .S LEVCODE=$G(SUBDAT(SFILE,SUBIENS,6,"E"))
 .S ROATEXT=$G(SUBDAT(SFILE,SUBIENS,7,"E"))
 .S ROAQUAL=$G(SUBDAT(SFILE,SUBIENS,8,"E"))
 .S ROACODE=$G(SUBDAT(SFILE,SUBIENS,9,"E"))
 .I $L(TYPETEXT_TYPEQUAL_TYPECODE_LEVTEXT_LEVQUAL_LEVCODE_ROATEXT_ROAQUAL_ROACODE) D
 ..D C S @GBL@(CNT,0)="<SubstanceUse>"
 ..D C S @GBL@(CNT,0)="<Substance>"
 ..D C S @GBL@(CNT,0)="<Type>"
 ..D BL(GBL,.CNT,"Text",TYPETEXT)
 ..D BL(GBL,.CNT,"Qualifier",TYPEQUAL)
 ..D BL(GBL,.CNT,"Code",TYPECODE)
 ..D C S @GBL@(CNT,0)="</Type>"
 ..I $L(LEVTEXT_LEVQUAL_LEVCODE) D
 ...D C S @GBL@(CNT,0)="<Level>"
 ...D BL(GBL,.CNT,"Text",LEVTEXT)
 ...D BL(GBL,.CNT,"Qualifier",LEVQUAL)
 ...D BL(GBL,.CNT,"Code",LEVCODE)
 ...D C S @GBL@(CNT,0)="</Level>"
 ..I $L(ROATEXT_ROAQUAL_ROACODE) D
 ...D C S @GBL@(CNT,0)="<RouteOfAdministration>"
 ...D BL(GBL,.CNT,"Text",ROATEXT)
 ...D BL(GBL,.CNT,"Qualifier",ROAQUAL)
 ...D BL(GBL,.CNT,"Code",ROACODE)
 ...D C S @GBL@(CNT,0)="</RouteOfAdministration>"
 ..D C S @GBL@(CNT,0)="</Substance>"
 ..D C S @GBL@(CNT,0)="</SubstanceUse>"
 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