PSOERXID ;ALB/BWF - eRx Utilities/RPC's ; 8/3/2016 5:14pm
;;7.0;OUTPATIENT PHARMACY;**581,635**;DEC 1997;Build 19
;
Q
ALLERGY(IEN,MYTPE) ; parsing and filing into allergy multiple
N AGL,I,IENS,SEQUENCE,SOI,EFFD,EXPD,ADVET,ADVEC,DPC,DPQ,DPT,RT,RC,ST,SC,FDA,NKA
S AGL=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"AllergyOrAdverseEvent",0))
S I=-1,SF=52.49303,IENS=IEN_",",SEQUENCE=0
F S I=$O(@AGL@("Allergies",I)) Q:I="" D
.S SEQUENCE=SEQUENCE+1
.S SOI=$G(@AGL@("Allergies",I,"SourceOfInformation",0))
.S EFFD=$G(@AGL@("Allergies",I,"EffectiveDate",0,"Date",0))
.I '$L(EFFD) S EFFD=$G(@AGL@("Allergies",I,"EffectiveDate",0,"DateTime",0))
.S EFFD=$$CONVDTTM^PSOERXA1(EFFD)
.S EXPD=$G(@AGL@("Allergies",I,"ExpirationDate",0,"Date",0))
.I '$L(EXPD) S EXPD=$G(@AGL@("Allergies",I,"ExpirationDate",0,"DateTime",0))
.S EXPD=$$CONVDTTM^PSOERXA1(EXPD)
.S ADVET=$G(@AGL@("Allergies",I,"AdverseEvent",0,"Text",0))
.S ADVEC=$G(@AGL@("Allergies",I,"AdverseEvent",0,"Code",0))
.S DPC=$G(@AGL@("Allergies",I,"DrugProductCoded",0,"Code",0))
.S DPQ=$G(@AGL@("Allergies",I,"DrugProductCoded",0,"Qualifier",0))
.S DPT=$G(@AGL@("Allergies",I,"DrugProductCoded",0,"Text",0))
.S RT=$G(@AGL@("Allergies",I,"ReactionCoded",0,"Text",0))
.S RC=$G(@AGL@("Allergies",I,"ReactionCoded",0,"Code",0))
.S ST=$G(@AGL@("Allergies",I,"SeverityCoded",0,"Text",0))
.S SC=$G(@AGL@("Allergies",I,"SeverityCoded",0,"Code",0))
.S FDA(SF,"+"_SEQUENCE_","_IENS,.01)=SEQUENCE
.S FDA(SF,"+"_SEQUENCE_","_IENS,.02)=SOI ; source of information
.S FDA(SF,"+"_SEQUENCE_","_IENS,.03)=EFFD ; effective date
.S FDA(SF,"+"_SEQUENCE_","_IENS,.04)=EXPD ; expiration date
.S FDA(SF,"+"_SEQUENCE_","_IENS,1)=DPC ; drug product code
.S FDA(SF,"+"_SEQUENCE_","_IENS,2)=DPQ ; drug product qualifier
.S FDA(SF,"+"_SEQUENCE_","_IENS,3)=DPT ; drug product text
.S FDA(SF,"+"_SEQUENCE_","_IENS,4)=RT ; reaction text
.S FDA(SF,"+"_SEQUENCE_","_IENS,5)=RC ; reaction code
.S FDA(SF,"+"_SEQUENCE_","_IENS,6)=ST ; severity text
.S FDA(SF,"+"_SEQUENCE_","_IENS,7)=SC ; severity code
.S FDA(SF,"+"_SEQUENCE_","_IENS,8)=ADVET ; adverse event text
.S FDA(SF,"+"_SEQUENCE_","_IENS,9)=ADVEC ; adverse event code
D CFDA^PSOERXIU(.FDA)
D UPDATE^DIE(,"FDA") K FDA
S NKA=$G(@AGL@("NoKnownAllergies",0)),FDA(52.49,IEN_",",302)=NKA
D FILE^DIE(,"FDA")
Q
;
BENEFITS(IEN,MTYPE) ;parsing and filing benefits coordination data
N BGL,F,SF,FDA,IENS,SEQUENCE,I,IIN,MUTDEF,NAIC,PATERID,PIN,SUHID,PATNAME,CHID,BCHGL,CARDNAME,CHLN,CHFN,CHMN,CHSUFF,CHPREF,GID
N PAYRC,PATREL,PCODE,GNAME,BGLA,ADDRESS,ADL1,ADL2,CITY,POSTAL,STATE,CC,PBM,BGLN,RESPARTY,RPLN,RPFN,RPMN,RPSUFF,RPPREF,PAYTYPE
N BGLC,NIEN,NEWIEN,PAYERID,PAYNAME
S BGL=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0))
S BGLC=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"BenefitsCoordination",0))
S F=52.49304,SF=52.493046,IENS=IEN_",",SEQUENCE=0,I=-1
F S I=$O(@BGL@("BenefitsCoordination",I)) Q:I="" D
.S SEQUENCE=SEQUENCE+1
.S IIN=$G(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"IINNumber",0))
.S MUTDEF=$G(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"MutuallyDefined",0))
.S NAIC=$G(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"NAICCode",0))
.S PAYERID=$G(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"PayerID",0))
.S PIN=$G(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"ProcessorIdentificationNumber",0))
.S SUHID=$G(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"StandardUniqueHealthPlanIdentifier",0))
.S PAYNAME=$G(@BGL@("BenefitsCoordination",I,"PayerName",0))
.S CHID=$G(@BGL@("BenefitsCoordination",0,"CardholderID",I))
.S BCHGL=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"BenefitsCoordination",I,"CardHolderName",0))
.S CARDNAME=$$NAME^PSOERXIU(BCHGL)
.S CHLN=$P(CARDNAME,U,1),CHFN=$P(CARDNAME,U,2),CHMN=$P(CARDNAME,U,3),CHSUFF=$P(CARDNAME,U,4),CHPREF=$P(CARDNAME,U,5)
.S GID=$G(@BGL@("BenefitsCoordination",I,"GroupID",0))
.S PAYRC=$G(@BGL@("BenefitsCoordination",I,"PayerResponsibilityCode",0))
.S PATREL=$G(@BGL@("BenefitsCoordination",I,"PatientRelationship",0))
.S PCODE=$G(@BGL@("BenefitsCoordination",I,"PersonCode",0))
.S GNAME=$G(@BGL@("BenefitsCoordination",I,"GroupName",0))
.S BGLA=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"BenefitsCoordination",I,"Address",0))
.S ADDRESS=$$ADDRESS^PSOERXIU(BGLA)
.S ADL1=$P(ADDRESS,U,1),ADL2=$P(ADDRESS,U,2),CITY=$P(ADDRESS,U,3),POSTAL=$P(ADDRESS,U,5),STATE=$P(ADDRESS,U,4),CC=$P(ADDRESS,U,6)
.S STATE=$$STRES^PSOERXA2(POSTAL,STATE)
.S PBM=$G(@BGL@("BenefitsCoordination",I,"PBMMemberID",0))
.S BGLN=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"BenefitsCoordination",I,"ResponsibleParty",0))
.S RESPARTY=$$NAME^PSOERXIU(BGLN)
.S RPLN=$P(RESPARTY,U,1),RPFN=$P(RESPARTY,U,2),RPMN=$P(RESPARTY,U,3),RPSUFF=$P(RESPARTY,U,4),RPPREF=$P(RESPARTY,U,5)
.S PAYTYPE=$G(@BGL@("BenefitsCoordination",I,"PayerType",0)),PAYTYPE=$$PRESOLV^PSOERXA1(PAYTYPE,"PAY")
.; sequence, payer ID, processor ID number, NAIC code
.S FDA(F,"+"_SEQUENCE_","_IENS,.01)=SEQUENCE,FDA(F,"+"_SEQUENCE_","_IENS,.02)=PAYERID,FDA(F,"+"_SEQUENCE_","_IENS,.03)=PIN,FDA(F,"+"_SEQUENCE_","_IENS,.04)=NAIC
.; mutually defined, health plan identifier, IIN number
.S FDA(F,"+"_SEQUENCE_","_IENS,1.1)=IIN,FDA(F,"+"_SEQUENCE_","_IENS,1.2)=SUHID,FDA(F,"+"_SEQUENCE_","_IENS,1.3)=IIN
.; payer name, cardholder ID
.S FDA(F,"+"_SEQUENCE_","_IENS,2.1)=PAYNAME,FDA(F,"+"_SEQUENCE_","_IENS,2.2)=CHID
.; cardhold name
.S FDA(F,"+"_SEQUENCE_","_IENS,3.1)=CHLN,FDA(F,"+"_SEQUENCE_","_IENS,3.2)=CHFN,FDA(F,"+"_SEQUENCE_","_IENS,3.3)=CHMN
.S FDA(F,"+"_SEQUENCE_","_IENS,3.4)=CHSUFF,FDA(F,"+"_SEQUENCE_","_IENS,3.5)=CHPREF
.; group ID, payer responsibility code, patient realtionship code, person code, group name
.S FDA(F,"+"_SEQUENCE_","_IENS,4.1)=GID,FDA(F,"+"_SEQUENCE_","_IENS,4.3)=PAYRC,FDA(F,"+"_SEQUENCE_","_IENS,4.4)=PATREL
.S FDA(F,"+"_SEQUENCE_","_IENS,4.5)=PCODE,FDA(F,"+"_SEQUENCE_","_IENS,4.6)=GNAME
.; address info
.S FDA(F,"+"_SEQUENCE_","_IENS,5.1)=ADL1,FDA(F,"+"_SEQUENCE_","_IENS,5.2)=ADL2,FDA(F,"+"_SEQUENCE_","_IENS,5.3)=CITY
.S FDA(F,"+"_SEQUENCE_","_IENS,5.4)=STATE,FDA(F,"+"_SEQUENCE_","_IENS,5.5)=POSTAL,FDA(F,"+"_SEQUENCE_","_IENS,5.6)=CC
.; PBM member ID
.S FDA(F,"+"_SEQUENCE_","_IENS,15.1)=PBM
.; responsible party name info
.S FDA(F,"+"_SEQUENCE_","_IENS,16.1)=RPLN,FDA(F,"+"_SEQUENCE_","_IENS,16.2)=RPFN,FDA(F,"+"_SEQUENCE_","_IENS,16.3)=RPMN
.S FDA(F,"+"_SEQUENCE_","_IENS,16.4)=RPSUFF,FDA(F,"+"_SEQUENCE_","_IENS,16.5)=RPPREF
.; payer type
.S FDA(F,"+"_SEQUENCE_","_IENS,16.6)=PAYTYPE
.D CFDA^PSOERXIU(.FDA)
.D UPDATE^DIE(,"FDA","NEWIEN") K FDA
.S NIEN=$O(NEWIEN(0)),NIEN=$G(NEWIEN(NIEN))
.D COMM^PSOERXIU(BGLC,SF,NIEN_","_IEN,52.49304,7) ;parse and file benefits coordination communication
.K NEWIEN
Q
FACILITY(IEN,MTYPE) ; parsing and filing facility data
N FLG,FGLA,F,SF,IENS,SEQUENCE,FACNAME,NCPDPID,SLN,MEDICARE,MEDICAID,UPIN,FACID,DEA,HIN,NPI,MUTDEF,REMS,FACADD
N FDA,AL1,ADL2,CITY,STATE,POSTAL,CC,FGLC,FGL,UIC
S FGL=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0))
S FGLC=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"Facility",0))
S FGLA=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"Facility",0,"Address",0))
S F=52.49,SF=52.4973,IENS=IEN_",",SEQUENCE=0
S FACNAME=$G(@FGL@("Facility",0,"FacilityName",0))
S NCPDPID=$G(@FGL@("Facility",0,"Identification",0,"NCPDPID",0))
S SLN=$G(@FGL@("Facility",0,"Identification",0,"StateLicenseNumber",0))
S MEDICARE=$G(@FGL@("Facility",0,"Identification",0,"MedicareNumber",0))
S MEDICAID=$G(@FGL@("Facility",0,"Identification",0,"MedicaidNumber",0))
S UPIN=$G(@FGL@("Facility",0,"Identification",0,"UPIN",0))
S FACID=$G(@FGL@("Facility",0,"Identification",0,"FacilityID",0))
S DEA=$G(@FGL@("Facility",0,"Identification",0,"DEANumber",0))
S HIN=$G(@FGL@("Facility",0,"Identification",0,"HIN",0))
S NPI=$G(@FGL@("Facility",0,"Identification",0,"NPI",0))
S MUTDEF=$G(@FGL@("Facility",0,"Identification",0,"MutuallyDefined",0))
S REMS=$G(@FGL@("Facility",0,"Identification",0,"REMSHealthcareSettingEnrollmentID",0))
S FACADD=$$ADDRESS^PSOERXIU(FGLA)
S ADL1=$P(FACADD,U,1),ADL2=$P(FACADD,U,2),CITY=$P(FACADD,U,3),POSTAL=$P(FACADD,U,5),STATE=$P(FACADD,U,4),CC=$P(FACADD,U,6)
S STATE=$$STRES^PSOERXA2(POSTAL,STATE)
;facility name and address data
S FDA(F,IENS,70.1)=FACNAME,FDA(F,IENS,70.2)=ADL1,FDA(F,IENS,70.3)=ADL2,FDA(F,IENS,70.4)=CITY
S FDA(F,IENS,70.5)=STATE,FDA(F,IENS,70.6)=POSTAL,FDA(F,IENS,70.7)=CC
;facility ID
S FDA(F,IENS,74.1)=NCPDPID,FDA(F,IENS,74.2)=SLN,FDA(F,IENS,74.3)=MEDICARE,FDA(F,IENS,74.4)=MEDICAID
S FDA(F,IENS,74.5)=UPIN,FDA(F,IENS,74.6)=FACID,FDA(F,IENS,75.1)=DEA,FDA(F,IENS,75.2)=HIN
S FDA(F,IENS,75.3)=NPI,FDA(F,IENS,75.4)=MUTDEF,FDA(F,IENS,75.5)=REMS
D CFDA^PSOERXIU(.FDA)
D UPDATE^DIE(,"FDA") K FDA
D COMM^PSOERXIU(FGLC,SF,IEN,52.49,76) ; parse and file facility communication data
Q
OBSERV(IEN,MTYPE) ; parsing and filing observation data
N OGL,I,F,IENS,SEQUENCE,VSIGN,LOIN,VALUE,UOM,UCUM,OBDATE,FDA,OBNOTES,LGL,LTCLOC,PROREN
S OGL=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"Observation",0))
S I=-1,F=52.49306,IENS=IEN_",",SEQUENCE=0
F S I=$O(@OGL@("Measurement",I)) Q:I="" D
.S SEQUENCE=SEQUENCE+1
.S VSIGN=$G(@OGL@("Measurement",I,"VitalSign",0))
.S LOIN=$G(@OGL@("Measurement",I,"LOINCVersion",0))
.S VALUE=$G(@OGL@("Measurement",I,"Value",0))
.S UOM=$G(@OGL@("Measurement",I,"UnitOfMeasure",0))
.S UCUM=$G(@OGL@("Measurement",I,"UCUMVersion",0))
.S OBDATE=$G(@OGL@("Measurement",I,"ObservationDate",0,"Date",0))
.;PSO*7*635 - check DateTime if Date was not passed in (at least one is required for the observation)
.I '$L(OBDATE) S OBDATE=$G(@OGL@("Measurement",I,"ObservationDate",0,"DateTime",0))
.S OBDATE=$$CONVDTTM^PSOERXA1(OBDATE)
.; sequence, vital sign, LOINCVersion, value, unit of measure, UCUM version, Observation date
.S FDA(F,"+"_SEQUENCE_","_IENS,.01)=SEQUENCE,FDA(F,"+"_SEQUENCE_","_IENS,1)=VSIGN,FDA(F,"+"_SEQUENCE_","_IENS,2)=LOIN,FDA(F,"+"_SEQUENCE_","_IENS,3)=VALUE
.S FDA(F,"+"_SEQUENCE_","_IENS,4)=UOM,FDA(F,"+"_SEQUENCE_","_IENS,5)=UCUM,FDA(F,"+"_SEQUENCE_","_IENS,6)=OBDATE
D CFDA^PSOERXIU(.FDA)
D UPDATE^DIE(,"FDA") K FDA
S OBNOTES=$G(@OGL@("ObservationNotes",0))
S LGL=$NA(^TMP($J,"PSOERXO1","Message",0,"Body",0,MTYPE,0))
S LTCLOC=$G(@LGL@("MessageRequestCode",0))
;/JSG/ PSO*7.0*581 - BEGIN CHANGE (Fix Prohibit Renewal Request)
S PROREN=$G(@LGL@("ProhibitRenewalRequest",0))
S PROREN=$S(PROREN="true":1,PROREN="false":0,1:"")
;/JSG/ - END CHANGE
S UIC=$G(@LGL@("UrgencyIndicatorCode",0))
S FDA(52.49,IEN_",",301.1)=LTCLOC,FDA(52.49,IEN_",",301.2)=UIC,FDA(52.49,IEN_",",301.3)=PROREN
S FDA(52.49,IEN_",",305)=OBNOTES
D CFDA^PSOERXIU(.FDA)
D FILE^DIE(,"FDA") K FDA
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSOERXID 10948 printed Nov 22, 2024@17:38:38 Page 2
PSOERXID ;ALB/BWF - eRx Utilities/RPC's ; 8/3/2016 5:14pm
+1 ;;7.0;OUTPATIENT PHARMACY;**581,635**;DEC 1997;Build 19
+2 ;
+3 QUIT
ALLERGY(IEN,MYTPE) ; parsing and filing into allergy multiple
+1 NEW AGL,I,IENS,SEQUENCE,SOI,EFFD,EXPD,ADVET,ADVEC,DPC,DPQ,DPT,RT,RC,ST,SC,FDA,NKA
+2 SET AGL=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"AllergyOrAdverseEvent",0))
+3 SET I=-1
SET SF=52.49303
SET IENS=IEN_","
SET SEQUENCE=0
+4 FOR
SET I=$ORDER(@AGL@("Allergies",I))
if I=""
QUIT
Begin DoDot:1
+5 SET SEQUENCE=SEQUENCE+1
+6 SET SOI=$GET(@AGL@("Allergies",I,"SourceOfInformation",0))
+7 SET EFFD=$GET(@AGL@("Allergies",I,"EffectiveDate",0,"Date",0))
+8 IF '$LENGTH(EFFD)
SET EFFD=$GET(@AGL@("Allergies",I,"EffectiveDate",0,"DateTime",0))
+9 SET EFFD=$$CONVDTTM^PSOERXA1(EFFD)
+10 SET EXPD=$GET(@AGL@("Allergies",I,"ExpirationDate",0,"Date",0))
+11 IF '$LENGTH(EXPD)
SET EXPD=$GET(@AGL@("Allergies",I,"ExpirationDate",0,"DateTime",0))
+12 SET EXPD=$$CONVDTTM^PSOERXA1(EXPD)
+13 SET ADVET=$GET(@AGL@("Allergies",I,"AdverseEvent",0,"Text",0))
+14 SET ADVEC=$GET(@AGL@("Allergies",I,"AdverseEvent",0,"Code",0))
+15 SET DPC=$GET(@AGL@("Allergies",I,"DrugProductCoded",0,"Code",0))
+16 SET DPQ=$GET(@AGL@("Allergies",I,"DrugProductCoded",0,"Qualifier",0))
+17 SET DPT=$GET(@AGL@("Allergies",I,"DrugProductCoded",0,"Text",0))
+18 SET RT=$GET(@AGL@("Allergies",I,"ReactionCoded",0,"Text",0))
+19 SET RC=$GET(@AGL@("Allergies",I,"ReactionCoded",0,"Code",0))
+20 SET ST=$GET(@AGL@("Allergies",I,"SeverityCoded",0,"Text",0))
+21 SET SC=$GET(@AGL@("Allergies",I,"SeverityCoded",0,"Code",0))
+22 SET FDA(SF,"+"_SEQUENCE_","_IENS,.01)=SEQUENCE
+23 ; source of information
SET FDA(SF,"+"_SEQUENCE_","_IENS,.02)=SOI
+24 ; effective date
SET FDA(SF,"+"_SEQUENCE_","_IENS,.03)=EFFD
+25 ; expiration date
SET FDA(SF,"+"_SEQUENCE_","_IENS,.04)=EXPD
+26 ; drug product code
SET FDA(SF,"+"_SEQUENCE_","_IENS,1)=DPC
+27 ; drug product qualifier
SET FDA(SF,"+"_SEQUENCE_","_IENS,2)=DPQ
+28 ; drug product text
SET FDA(SF,"+"_SEQUENCE_","_IENS,3)=DPT
+29 ; reaction text
SET FDA(SF,"+"_SEQUENCE_","_IENS,4)=RT
+30 ; reaction code
SET FDA(SF,"+"_SEQUENCE_","_IENS,5)=RC
+31 ; severity text
SET FDA(SF,"+"_SEQUENCE_","_IENS,6)=ST
+32 ; severity code
SET FDA(SF,"+"_SEQUENCE_","_IENS,7)=SC
+33 ; adverse event text
SET FDA(SF,"+"_SEQUENCE_","_IENS,8)=ADVET
+34 ; adverse event code
SET FDA(SF,"+"_SEQUENCE_","_IENS,9)=ADVEC
End DoDot:1
+35 DO CFDA^PSOERXIU(.FDA)
+36 DO UPDATE^DIE(,"FDA")
KILL FDA
+37 SET NKA=$GET(@AGL@("NoKnownAllergies",0))
SET FDA(52.49,IEN_",",302)=NKA
+38 DO FILE^DIE(,"FDA")
+39 QUIT
+40 ;
BENEFITS(IEN,MTYPE) ;parsing and filing benefits coordination data
+1 NEW BGL,F,SF,FDA,IENS,SEQUENCE,I,IIN,MUTDEF,NAIC,PATERID,PIN,SUHID,PATNAME,CHID,BCHGL,CARDNAME,CHLN,CHFN,CHMN,CHSUFF,CHPREF,GID
+2 NEW PAYRC,PATREL,PCODE,GNAME,BGLA,ADDRESS,ADL1,ADL2,CITY,POSTAL,STATE,CC,PBM,BGLN,RESPARTY,RPLN,RPFN,RPMN,RPSUFF,RPPREF,PAYTYPE
+3 NEW BGLC,NIEN,NEWIEN,PAYERID,PAYNAME
+4 SET BGL=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0))
+5 SET BGLC=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"BenefitsCoordination",0))
+6 SET F=52.49304
SET SF=52.493046
SET IENS=IEN_","
SET SEQUENCE=0
SET I=-1
+7 FOR
SET I=$ORDER(@BGL@("BenefitsCoordination",I))
if I=""
QUIT
Begin DoDot:1
+8 SET SEQUENCE=SEQUENCE+1
+9 SET IIN=$GET(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"IINNumber",0))
+10 SET MUTDEF=$GET(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"MutuallyDefined",0))
+11 SET NAIC=$GET(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"NAICCode",0))
+12 SET PAYERID=$GET(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"PayerID",0))
+13 SET PIN=$GET(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"ProcessorIdentificationNumber",0))
+14 SET SUHID=$GET(@BGL@("BenefitsCoordination",I,"PayerIdentification",0,"StandardUniqueHealthPlanIdentifier",0))
+15 SET PAYNAME=$GET(@BGL@("BenefitsCoordination",I,"PayerName",0))
+16 SET CHID=$GET(@BGL@("BenefitsCoordination",0,"CardholderID",I))
+17 SET BCHGL=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"BenefitsCoordination",I,"CardHolderName",0))
+18 SET CARDNAME=$$NAME^PSOERXIU(BCHGL)
+19 SET CHLN=$PIECE(CARDNAME,U,1)
SET CHFN=$PIECE(CARDNAME,U,2)
SET CHMN=$PIECE(CARDNAME,U,3)
SET CHSUFF=$PIECE(CARDNAME,U,4)
SET CHPREF=$PIECE(CARDNAME,U,5)
+20 SET GID=$GET(@BGL@("BenefitsCoordination",I,"GroupID",0))
+21 SET PAYRC=$GET(@BGL@("BenefitsCoordination",I,"PayerResponsibilityCode",0))
+22 SET PATREL=$GET(@BGL@("BenefitsCoordination",I,"PatientRelationship",0))
+23 SET PCODE=$GET(@BGL@("BenefitsCoordination",I,"PersonCode",0))
+24 SET GNAME=$GET(@BGL@("BenefitsCoordination",I,"GroupName",0))
+25 SET BGLA=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"BenefitsCoordination",I,"Address",0))
+26 SET ADDRESS=$$ADDRESS^PSOERXIU(BGLA)
+27 SET ADL1=$PIECE(ADDRESS,U,1)
SET ADL2=$PIECE(ADDRESS,U,2)
SET CITY=$PIECE(ADDRESS,U,3)
SET POSTAL=$PIECE(ADDRESS,U,5)
SET STATE=$PIECE(ADDRESS,U,4)
SET CC=$PIECE(ADDRESS,U,6)
+28 SET STATE=$$STRES^PSOERXA2(POSTAL,STATE)
+29 SET PBM=$GET(@BGL@("BenefitsCoordination",I,"PBMMemberID",0))
+30 SET BGLN=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"BenefitsCoordination",I,"ResponsibleParty",0))
+31 SET RESPARTY=$$NAME^PSOERXIU(BGLN)
+32 SET RPLN=$PIECE(RESPARTY,U,1)
SET RPFN=$PIECE(RESPARTY,U,2)
SET RPMN=$PIECE(RESPARTY,U,3)
SET RPSUFF=$PIECE(RESPARTY,U,4)
SET RPPREF=$PIECE(RESPARTY,U,5)
+33 SET PAYTYPE=$GET(@BGL@("BenefitsCoordination",I,"PayerType",0))
SET PAYTYPE=$$PRESOLV^PSOERXA1(PAYTYPE,"PAY")
+34 ; sequence, payer ID, processor ID number, NAIC code
+35 SET FDA(F,"+"_SEQUENCE_","_IENS,.01)=SEQUENCE
SET FDA(F,"+"_SEQUENCE_","_IENS,.02)=PAYERID
SET FDA(F,"+"_SEQUENCE_","_IENS,.03)=PIN
SET FDA(F,"+"_SEQUENCE_","_IENS,.04)=NAIC
+36 ; mutually defined, health plan identifier, IIN number
+37 SET FDA(F,"+"_SEQUENCE_","_IENS,1.1)=IIN
SET FDA(F,"+"_SEQUENCE_","_IENS,1.2)=SUHID
SET FDA(F,"+"_SEQUENCE_","_IENS,1.3)=IIN
+38 ; payer name, cardholder ID
+39 SET FDA(F,"+"_SEQUENCE_","_IENS,2.1)=PAYNAME
SET FDA(F,"+"_SEQUENCE_","_IENS,2.2)=CHID
+40 ; cardhold name
+41 SET FDA(F,"+"_SEQUENCE_","_IENS,3.1)=CHLN
SET FDA(F,"+"_SEQUENCE_","_IENS,3.2)=CHFN
SET FDA(F,"+"_SEQUENCE_","_IENS,3.3)=CHMN
+42 SET FDA(F,"+"_SEQUENCE_","_IENS,3.4)=CHSUFF
SET FDA(F,"+"_SEQUENCE_","_IENS,3.5)=CHPREF
+43 ; group ID, payer responsibility code, patient realtionship code, person code, group name
+44 SET FDA(F,"+"_SEQUENCE_","_IENS,4.1)=GID
SET FDA(F,"+"_SEQUENCE_","_IENS,4.3)=PAYRC
SET FDA(F,"+"_SEQUENCE_","_IENS,4.4)=PATREL
+45 SET FDA(F,"+"_SEQUENCE_","_IENS,4.5)=PCODE
SET FDA(F,"+"_SEQUENCE_","_IENS,4.6)=GNAME
+46 ; address info
+47 SET FDA(F,"+"_SEQUENCE_","_IENS,5.1)=ADL1
SET FDA(F,"+"_SEQUENCE_","_IENS,5.2)=ADL2
SET FDA(F,"+"_SEQUENCE_","_IENS,5.3)=CITY
+48 SET FDA(F,"+"_SEQUENCE_","_IENS,5.4)=STATE
SET FDA(F,"+"_SEQUENCE_","_IENS,5.5)=POSTAL
SET FDA(F,"+"_SEQUENCE_","_IENS,5.6)=CC
+49 ; PBM member ID
+50 SET FDA(F,"+"_SEQUENCE_","_IENS,15.1)=PBM
+51 ; responsible party name info
+52 SET FDA(F,"+"_SEQUENCE_","_IENS,16.1)=RPLN
SET FDA(F,"+"_SEQUENCE_","_IENS,16.2)=RPFN
SET FDA(F,"+"_SEQUENCE_","_IENS,16.3)=RPMN
+53 SET FDA(F,"+"_SEQUENCE_","_IENS,16.4)=RPSUFF
SET FDA(F,"+"_SEQUENCE_","_IENS,16.5)=RPPREF
+54 ; payer type
+55 SET FDA(F,"+"_SEQUENCE_","_IENS,16.6)=PAYTYPE
+56 DO CFDA^PSOERXIU(.FDA)
+57 DO UPDATE^DIE(,"FDA","NEWIEN")
KILL FDA
+58 SET NIEN=$ORDER(NEWIEN(0))
SET NIEN=$GET(NEWIEN(NIEN))
+59 ;parse and file benefits coordination communication
DO COMM^PSOERXIU(BGLC,SF,NIEN_","_IEN,52.49304,7)
+60 KILL NEWIEN
End DoDot:1
+61 QUIT
FACILITY(IEN,MTYPE) ; parsing and filing facility data
+1 NEW FLG,FGLA,F,SF,IENS,SEQUENCE,FACNAME,NCPDPID,SLN,MEDICARE,MEDICAID,UPIN,FACID,DEA,HIN,NPI,MUTDEF,REMS,FACADD
+2 NEW FDA,AL1,ADL2,CITY,STATE,POSTAL,CC,FGLC,FGL,UIC
+3 SET FGL=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0))
+4 SET FGLC=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"Facility",0))
+5 SET FGLA=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"Facility",0,"Address",0))
+6 SET F=52.49
SET SF=52.4973
SET IENS=IEN_","
SET SEQUENCE=0
+7 SET FACNAME=$GET(@FGL@("Facility",0,"FacilityName",0))
+8 SET NCPDPID=$GET(@FGL@("Facility",0,"Identification",0,"NCPDPID",0))
+9 SET SLN=$GET(@FGL@("Facility",0,"Identification",0,"StateLicenseNumber",0))
+10 SET MEDICARE=$GET(@FGL@("Facility",0,"Identification",0,"MedicareNumber",0))
+11 SET MEDICAID=$GET(@FGL@("Facility",0,"Identification",0,"MedicaidNumber",0))
+12 SET UPIN=$GET(@FGL@("Facility",0,"Identification",0,"UPIN",0))
+13 SET FACID=$GET(@FGL@("Facility",0,"Identification",0,"FacilityID",0))
+14 SET DEA=$GET(@FGL@("Facility",0,"Identification",0,"DEANumber",0))
+15 SET HIN=$GET(@FGL@("Facility",0,"Identification",0,"HIN",0))
+16 SET NPI=$GET(@FGL@("Facility",0,"Identification",0,"NPI",0))
+17 SET MUTDEF=$GET(@FGL@("Facility",0,"Identification",0,"MutuallyDefined",0))
+18 SET REMS=$GET(@FGL@("Facility",0,"Identification",0,"REMSHealthcareSettingEnrollmentID",0))
+19 SET FACADD=$$ADDRESS^PSOERXIU(FGLA)
+20 SET ADL1=$PIECE(FACADD,U,1)
SET ADL2=$PIECE(FACADD,U,2)
SET CITY=$PIECE(FACADD,U,3)
SET POSTAL=$PIECE(FACADD,U,5)
SET STATE=$PIECE(FACADD,U,4)
SET CC=$PIECE(FACADD,U,6)
+21 SET STATE=$$STRES^PSOERXA2(POSTAL,STATE)
+22 ;facility name and address data
+23 SET FDA(F,IENS,70.1)=FACNAME
SET FDA(F,IENS,70.2)=ADL1
SET FDA(F,IENS,70.3)=ADL2
SET FDA(F,IENS,70.4)=CITY
+24 SET FDA(F,IENS,70.5)=STATE
SET FDA(F,IENS,70.6)=POSTAL
SET FDA(F,IENS,70.7)=CC
+25 ;facility ID
+26 SET FDA(F,IENS,74.1)=NCPDPID
SET FDA(F,IENS,74.2)=SLN
SET FDA(F,IENS,74.3)=MEDICARE
SET FDA(F,IENS,74.4)=MEDICAID
+27 SET FDA(F,IENS,74.5)=UPIN
SET FDA(F,IENS,74.6)=FACID
SET FDA(F,IENS,75.1)=DEA
SET FDA(F,IENS,75.2)=HIN
+28 SET FDA(F,IENS,75.3)=NPI
SET FDA(F,IENS,75.4)=MUTDEF
SET FDA(F,IENS,75.5)=REMS
+29 DO CFDA^PSOERXIU(.FDA)
+30 DO UPDATE^DIE(,"FDA")
KILL FDA
+31 ; parse and file facility communication data
DO COMM^PSOERXIU(FGLC,SF,IEN,52.49,76)
+32 QUIT
OBSERV(IEN,MTYPE) ; parsing and filing observation data
+1 NEW OGL,I,F,IENS,SEQUENCE,VSIGN,LOIN,VALUE,UOM,UCUM,OBDATE,FDA,OBNOTES,LGL,LTCLOC,PROREN
+2 SET OGL=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0,"Observation",0))
+3 SET I=-1
SET F=52.49306
SET IENS=IEN_","
SET SEQUENCE=0
+4 FOR
SET I=$ORDER(@OGL@("Measurement",I))
if I=""
QUIT
Begin DoDot:1
+5 SET SEQUENCE=SEQUENCE+1
+6 SET VSIGN=$GET(@OGL@("Measurement",I,"VitalSign",0))
+7 SET LOIN=$GET(@OGL@("Measurement",I,"LOINCVersion",0))
+8 SET VALUE=$GET(@OGL@("Measurement",I,"Value",0))
+9 SET UOM=$GET(@OGL@("Measurement",I,"UnitOfMeasure",0))
+10 SET UCUM=$GET(@OGL@("Measurement",I,"UCUMVersion",0))
+11 SET OBDATE=$GET(@OGL@("Measurement",I,"ObservationDate",0,"Date",0))
+12 ;PSO*7*635 - check DateTime if Date was not passed in (at least one is required for the observation)
+13 IF '$LENGTH(OBDATE)
SET OBDATE=$GET(@OGL@("Measurement",I,"ObservationDate",0,"DateTime",0))
+14 SET OBDATE=$$CONVDTTM^PSOERXA1(OBDATE)
+15 ; sequence, vital sign, LOINCVersion, value, unit of measure, UCUM version, Observation date
+16 SET FDA(F,"+"_SEQUENCE_","_IENS,.01)=SEQUENCE
SET FDA(F,"+"_SEQUENCE_","_IENS,1)=VSIGN
SET FDA(F,"+"_SEQUENCE_","_IENS,2)=LOIN
SET FDA(F,"+"_SEQUENCE_","_IENS,3)=VALUE
+17 SET FDA(F,"+"_SEQUENCE_","_IENS,4)=UOM
SET FDA(F,"+"_SEQUENCE_","_IENS,5)=UCUM
SET FDA(F,"+"_SEQUENCE_","_IENS,6)=OBDATE
End DoDot:1
+18 DO CFDA^PSOERXIU(.FDA)
+19 DO UPDATE^DIE(,"FDA")
KILL FDA
+20 SET OBNOTES=$GET(@OGL@("ObservationNotes",0))
+21 SET LGL=$NAME(^TMP($JOB,"PSOERXO1","Message",0,"Body",0,MTYPE,0))
+22 SET LTCLOC=$GET(@LGL@("MessageRequestCode",0))
+23 ;/JSG/ PSO*7.0*581 - BEGIN CHANGE (Fix Prohibit Renewal Request)
+24 SET PROREN=$GET(@LGL@("ProhibitRenewalRequest",0))
+25 SET PROREN=$SELECT(PROREN="true":1,PROREN="false":0,1:"")
+26 ;/JSG/ - END CHANGE
+27 SET UIC=$GET(@LGL@("UrgencyIndicatorCode",0))
+28 SET FDA(52.49,IEN_",",301.1)=LTCLOC
SET FDA(52.49,IEN_",",301.2)=UIC
SET FDA(52.49,IEN_",",301.3)=PROREN
+29 SET FDA(52.49,IEN_",",305)=OBNOTES
+30 DO CFDA^PSOERXIU(.FDA)
+31 DO FILE^DIE(,"FDA")
KILL FDA
+32 QUIT