public string GetPersonIdFieldName() { if (Persons != null && Persons.Any()) { return(Persons[0].PersonId); } if (PayerPlanPeriods != null && PayerPlanPeriods.Any()) { return(PayerPlanPeriods[0].PersonId); } if (ConditionOccurrence != null && ConditionOccurrence.Any()) { return(ConditionOccurrence[0].PersonId); } if (Death != null && Death.Any()) { return(Death[0].PersonId); } if (DrugExposure != null && DrugExposure.Any()) { return(DrugExposure[0].PersonId); } if (ProcedureOccurrence != null && ProcedureOccurrence.Any()) { return(ProcedureOccurrence[0].PersonId); } if (Observation != null && Observation.Any()) { return(Observation[0].PersonId); } if (Measurement != null && Measurement.Any()) { return(Measurement[0].PersonId); } if (VisitOccurrence != null && VisitOccurrence.Any()) { return(VisitOccurrence[0].PersonId); } if (Cohort != null && Cohort.Any()) { return(Cohort[0].PersonId); } if (DeviceExposure != null && DeviceExposure.Any()) { return(DeviceExposure[0].PersonId); } throw new Exception("Cant find PersonId FieldName " + this.FileName); }
public ProcedureCost(ProcedureOccurrence ent) : base(ent) { Init(ent); Id = ent.Id; SourceRecordGuid = ent.SourceRecordGuid; }
public ProcedureCost CreateEnity(ProcedureOccurrence procedure, IDataReader reader) { var paidCopay = reader.GetDecimal(PaidCopay); var paidCoinsurance = reader.GetDecimal(PaidCoinsurance); var paidTowardDeductible = reader.GetDecimal(PaidTowardDeductible); long? revenueCodeConceptId = null; string revenueCodeSource = null; long? diseaseClassConceptId = null; var diseaseClassSource = ""; var revenueCodeConcept = Concepts[0]; if (revenueCodeConcept.Fields.Length > 0) { revenueCodeSource = reader[revenueCodeConcept.Fields[0].Key].ToString().Trim(); var revenueConcepts = revenueCodeConcept.GetValues(Vocabulary, revenueCodeConcept.Fields[0], reader); if (revenueConcepts.Count > 0) { revenueCodeConceptId = revenueConcepts[0].ConceptId; } } string diseaseClassLookupKey = null; if (Concepts.Length == 2) { var diseaseClassConcept = Concepts[1]; diseaseClassSource = reader[diseaseClassConcept.Fields[0].Key].ToString().Trim(); var diseaseConcepts = diseaseClassConcept.GetValues(Vocabulary, diseaseClassConcept.Fields[0], reader); if (diseaseConcepts.Count > 0) { diseaseClassConceptId = diseaseConcepts[0].ConceptId; } diseaseClassLookupKey = diseaseClassConcept.GetConceptIdLookupKey(reader); } return(new ProcedureCost(procedure) { PaidCopay = paidCopay, PaidCoinsurance = paidCoinsurance, PaidTowardDeductible = paidTowardDeductible, PaidByPayer = reader.GetDecimal(PaidByPayer), PaidByCoordinationBenefits = reader.GetDecimal(PaidByCoordinationBenefits), TotalPaid = reader.GetDecimal(TotalPaid), TotalOutOfPocket = paidCopay + paidCoinsurance + paidTowardDeductible, RevenueCodeConceptId = revenueCodeConceptId, RevenueCodeSourceValue = revenueCodeSource, DiseaseClassConceptId = diseaseClassConceptId, DiseaseClassSourceValue = diseaseClassSource, DiseaseClassLookupKey = diseaseClassLookupKey }); }
private void AddChildData(ProcedureOccurrence parent, ProcedureCost child) { if (child.PaidCopay == 0 && child.PaidCoinsurance == 0 && child.PaidTowardDeductible == 0 && child.PaidByPayer == 0 && child.TotalPaid == 0) { return; } _personBuilders[parent.PersonId].Value.AddChildData(parent, child); }
public ProcedureCost CreateEnity(ProcedureOccurrence procedure, IDataReader reader) { var paidCopay = reader.GetDecimal(PaidCopay); var paidCoinsurance = reader.GetDecimal(PaidCoinsurance); var paidTowardDeductible = reader.GetDecimal(PaidTowardDeductible); long? revenueCodeConceptId = null; string revenueCodeSource = null; long? diseaseClassConceptId = null; var diseaseClassSource = ""; var revenueCodeConcept = Concepts[0]; if (revenueCodeConcept.Fields.Length > 0) { revenueCodeSource = reader[revenueCodeConcept.Fields[0].Key].ToString().Trim(); var revenueConcepts = revenueCodeConcept.GetValues(Vocabulary, revenueCodeConcept.Fields[0], reader); if(revenueConcepts.Count > 0) revenueCodeConceptId = revenueConcepts[0].ConceptId; } string diseaseClassLookupKey = null; if (Concepts.Length == 2) { var diseaseClassConcept = Concepts[1]; diseaseClassSource = reader[diseaseClassConcept.Fields[0].Key].ToString().Trim(); var diseaseConcepts = diseaseClassConcept.GetValues(Vocabulary, diseaseClassConcept.Fields[0], reader); if (diseaseConcepts.Count > 0) diseaseClassConceptId = diseaseConcepts[0].ConceptId; diseaseClassLookupKey = diseaseClassConcept.GetConceptIdLookupKey(reader); } return new ProcedureCost(procedure) { PaidCopay = paidCopay, PaidCoinsurance = paidCoinsurance, PaidTowardDeductible = paidTowardDeductible, PaidByPayer = reader.GetDecimal(PaidByPayer), PaidByCoordinationBenefits = reader.GetDecimal(PaidByCoordinationBenefits), TotalPaid = reader.GetDecimal(TotalPaid), TotalOutOfPocket = paidCopay + paidCoinsurance + paidTowardDeductible, RevenueCodeConceptId = revenueCodeConceptId, RevenueCodeSourceValue = revenueCodeSource, DiseaseClassConceptId = diseaseClassConceptId, DiseaseClassSourceValue = diseaseClassSource, DiseaseClassLookupKey = diseaseClassLookupKey }; }
public ProcedureCost CreateEnity(ProcedureOccurrence procedure, IDataRecord reader, KeyMasterOffset keyOffset) { var paidCopay = reader.GetDecimal(PaidCopay); var paidCoinsurance = reader.GetDecimal(PaidCoinsurance); var paidTowardDeductible = reader.GetDecimal(PaidTowardDeductible); decimal?totalOutOfPocket = null; if (paidCopay.HasValue && paidCoinsurance.HasValue && paidTowardDeductible.HasValue) { totalOutOfPocket = paidCopay + paidCoinsurance + paidTowardDeductible; } else if (paidCoinsurance.HasValue && paidTowardDeductible.HasValue) { totalOutOfPocket = paidCoinsurance + paidTowardDeductible; } long? drgConceptId; string drgSource; long? revenueCodeConceptId; string revenueCodeSource; PopulateOthersConcepts(reader, out drgConceptId, out drgSource, out revenueCodeConceptId, out revenueCodeSource); return(new ProcedureCost(procedure) { ProcedureCostId = keyOffset.ProcedureCostId, PaidCopay = paidCopay, PaidCoinsurance = paidCoinsurance, PaidTowardDeductible = paidTowardDeductible, PaidByPayer = reader.GetDecimal(PaidByPayer), PaidByCoordinationBenefits = reader.GetDecimal(PaidByCoordinationBenefits), TotalPaid = reader.GetDecimal(TotalPaid), TotalOutOfPocket = totalOutOfPocket, RevenueCodeConceptId = revenueCodeConceptId, RevenueCodeSourceValue = revenueCodeSource, DrgConceptId = drgConceptId, DrgSourceValue = drgSource, CurrencyConceptId = reader.GetLong(CurrencyConceptId) ?? 0 }); }
public ProcedureCost CreateEnity(ProcedureOccurrence procedure, IDataRecord reader, KeyMasterOffset keyOffset) { var paidCopay = reader.GetDecimal(PaidCopay); var paidCoinsurance = reader.GetDecimal(PaidCoinsurance); var paidTowardDeductible = reader.GetDecimal(PaidTowardDeductible); long? revenueCodeConceptId = null; string revenueCodeSource = null; long? diseaseClassConceptId = null; var diseaseClassSource = ""; string diseaseClassLookupKey = null; if (Concepts != null) { if (Concepts.Length > 0) { var revenueCodeConcept = Concepts[0]; if (revenueCodeConcept.Fields.Length > 0) { revenueCodeSource = reader.GetString(revenueCodeConcept.Fields[0].Key); var revenueConcepts = revenueCodeConcept.GetConceptIdValues(Vocabulary, revenueCodeConcept.Fields[0], reader); if (revenueConcepts.Count > 0) { revenueCodeConceptId = revenueConcepts[0].ConceptId; } } } if (Concepts.Length == 2) { var diseaseClassConcept = Concepts[1]; diseaseClassSource = reader.GetString(diseaseClassConcept.Fields[0].Key); var diseaseConcepts = diseaseClassConcept.GetConceptIdValues(Vocabulary, diseaseClassConcept.Fields[0], reader); if (diseaseConcepts.Count > 0) { diseaseClassConceptId = diseaseConcepts[0].ConceptId; } diseaseClassLookupKey = diseaseClassConcept.GetConceptIdLookupKey(reader); } } decimal?totalOutOfPocket = null; if (paidCopay.HasValue && paidCoinsurance.HasValue && paidTowardDeductible.HasValue) { totalOutOfPocket = paidCopay + paidCoinsurance + paidTowardDeductible; } else if (paidCoinsurance.HasValue && paidTowardDeductible.HasValue) { totalOutOfPocket = paidCoinsurance + paidTowardDeductible; } return(new ProcedureCost(procedure) { ProcedureCostId = keyOffset.ProcedureCostId, PaidCopay = paidCopay, PaidCoinsurance = paidCoinsurance, PaidTowardDeductible = paidTowardDeductible, PaidByPayer = reader.GetDecimal(PaidByPayer), PaidByCoordinationBenefits = reader.GetDecimal(PaidByCoordinationBenefits), TotalPaid = reader.GetDecimal(TotalPaid), TotalOutOfPocket = totalOutOfPocket, RevenueCodeConceptId = revenueCodeConceptId, RevenueCodeSourceValue = revenueCodeSource, DiseaseClassConceptId = diseaseClassConceptId, DiseaseClassSourceValue = diseaseClassSource, DiseaseClassLookupKey = diseaseClassLookupKey, CurrencyConceptId = reader.GetLong(CurrencyConceptId) ?? 0 }); }
protected override void SetPayerPlanPeriodId(PayerPlanPeriod[] payerPlanPeriods, DrugExposure[] drugExposures, ProcedureOccurrence[] procedureOccurrences) { if (!payerPlanPeriods.Any()) return; foreach (var de in drugExposures) { if (de.DrugCost == null) continue; foreach (var planPeriod in payerPlanPeriods) { if (de.StartDate.Between(planPeriod.StartDate, planPeriod.EndDate.Value) && !string.IsNullOrEmpty(de.DrugCost.AdditionalFields["pat_planid"]) && de.DrugCost.AdditionalFields["pat_planid"] == planPeriod.PlanSourceValue) { de.DrugCost.PayerPlanPeriodId = planPeriod.Id; break; } } } foreach (var po in procedureOccurrences) { if (po.ProcedureCosts == null) continue; foreach (var planPeriod in payerPlanPeriods) { if (po.StartDate.Between(planPeriod.StartDate, planPeriod.EndDate.Value)) { foreach (var procedureCost in po.ProcedureCosts) { if (procedureCost.AdditionalFields["pat_planid"] == planPeriod.PlanSourceValue) { procedureCost.PayerPlanPeriodId = planPeriod.Id; } } } } } }
/// <summary> /// Projects Enumeration of ProcedureOccurrence from the raw set of ProcedureOccurence entities. /// During build: /// override the procedure's start date using the end date of the corresponding visit. /// overide TypeConceptId per CDM Mapping spec. /// truncate procedure's dates to the corresponding observation period dates /// </summary> /// <param name="procedureOccurrences">raw set of procedure occurrence entities</param> /// <param name="visitOccurrences">the visit occurrence entities for current person</param> /// <param name="observationPeriods">the observation period entities for current person</param> /// <returns>Enumeration of procedure occurrence entities</returns> public override IEnumerable<ProcedureOccurrence> BuildProcedureOccurrences(ProcedureOccurrence[] procedureOccurrences, Dictionary<long, VisitOccurrence> visitOccurrences, ObservationPeriod[] observationPeriods) { var result = new HashSet<ProcedureOccurrence>(); var cost = new Dictionary<ProcedureOccurrence, List<ProcedureCost>>(); var dateClaimTypeDictionary = new Dictionary<DateTime, Dictionary<string, List<IEntity>>>(); var cdProcedures = new List<ProcedureOccurrence>(); var otherProcedures = new List<ProcedureOccurrence>(); foreach (var procedureOccurrence in procedureOccurrences) { var visitOccurrence = GetVisitOccurrence(procedureOccurrence); if (visitOccurrence == null) continue; procedureOccurrence.VisitOccurrenceId = visitOccurrence.Id; var observationPeriod = observationPeriods.FirstOrDefault(op => op.StartDate.Between(procedureOccurrence.StartDate, procedureOccurrence.EndDate.Value) || op.EndDate.Between(procedureOccurrence.StartDate, procedureOccurrence.EndDate.Value)); if (observationPeriod != null) { if (procedureOccurrence.StartDate < observationPeriod.StartDate) procedureOccurrence.StartDate = observationPeriod.StartDate; if (procedureOccurrence.StartDate > observationPeriod.EndDate) procedureOccurrence.StartDate = observationPeriod.EndDate; } procedureOccurrence.EndDate = null; procedureOccurrence.TypeConceptId = GetProcedureTypeConceptId(procedureOccurrence.TypeConceptId.Value, visitOccurrence.ConceptId); if (procedureOccurrence.TypeConceptId == 38000272 || procedureOccurrence.TypeConceptId == 38000254) { if (procedureOccurrence.ProcedureCosts != null) { if (!cost.ContainsKey(procedureOccurrence)) cost.Add(procedureOccurrence, new List<ProcedureCost>()); cost[procedureOccurrence].AddRange(procedureOccurrence.ProcedureCosts); } cdProcedures.Add(procedureOccurrence); } else { procedureOccurrence.StartDate = visitOccurrence.EndDate.Value; if (CodeValidator.IsValidIcd9Procedure(procedureOccurrence.SourceValue)) otherProcedures.Add(procedureOccurrence); } AddToDateClaimTypeDictionary(dateClaimTypeDictionary, procedureOccurrence, visitOccurrence); } foreach (var procedureOccurrence in BuildProceduresCd(cdProcedures, cost)) { result.Add(procedureOccurrence); } foreach (var procedureOccurrence in BuildProceduresOther(otherProcedures, visitOccurrences, dateClaimTypeDictionary)) { result.Add(procedureOccurrence); } return base.BuildProcedureOccurrences(result.ToArray(), visitOccurrences, observationPeriods); }
/// <summary> /// Projects Enumeration of procedure cost from the set of procedure occurrence entities. /// During build: /// override the procedure cost Id to the corresponding procedure occurrence Id /// calculate TotalOutOfPocket per CDM Mapping spec. /// </summary> /// <param name="procedureOccurrences">set of procedure occurrence entities</param> /// <returns>set of procedure cost entities</returns> public override IEnumerable<ProcedureCost> BuildProcedureCosts(ProcedureOccurrence[] procedureOccurrences) { // Don't put ICD9 procedure for PROC1-PROC3 in this table // proc1 TypeId = 38000251, 38000269 // proc2 TypeId = 38000252, 38000270 // proc3 TypeId = 38000253, 38000271 // proc_cd TypeId = 38000254, 38000272 foreach (var procedureOccurrence in procedureOccurrences) { if (procedureOccurrence.TypeConceptId != 38000254 && procedureOccurrence.TypeConceptId != 38000272) continue; foreach (var procedureCost in procedureOccurrence.ProcedureCosts) { //TOTAL_OUT_OF_POCKET = COINS + DEDUCT procedureCost.TotalOutOfPocket = procedureCost.PaidCoinsurance + procedureCost.PaidTowardDeductible; procedureCost.Id = procedureOccurrence.Id; yield return procedureCost; } } }
public void AddChildData(ProcedureOccurrence parent, ProcedureCost pc) { parent.ProcedureCosts = new List <ProcedureCost> { pc }; }