-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from OHDSI/cost-definition
Cost definition
- Loading branch information
Showing
10 changed files
with
225 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/Cost.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<QueryDefinition> | ||
<Query> | ||
SELECT cost_id | ||
, cost_event_id | ||
, cost_domain_id | ||
, cost_type_concept_id | ||
, currency_concept_id | ||
, total_charge | ||
, total_cost | ||
, total_paid | ||
|
||
, paid_by_payer | ||
, paid_by_patient | ||
, paid_patient_copay | ||
, paid_patient_coinsurance | ||
, paid_patient_deductible | ||
, paid_by_primary | ||
, paid_ingredient_cost | ||
, paid_dispensing_fee | ||
|
||
, payer_plan_period_id | ||
|
||
, amount_allowed | ||
, revenue_code_concept_id | ||
, revenue_code_source_value | ||
, drg_concept_id | ||
, drg_source_value | ||
, coalesce(po.person_id, o.person_id, d.person_id, dev.person_id, m.person_id, v.person_id) person_id | ||
FROM {sc}.cost | ||
left join {sc}.procedure_occurrence po on cost_domain_id = 'Procedure' and cost_event_id = po.procedure_occurrence_id | ||
left join {sc}.observation o on cost_domain_id = 'Observation' and cost_event_id = o.observation_id | ||
left join {sc}.drug_exposure d on cost_domain_id = 'Drug' and cost_event_id = d.drug_exposure_id | ||
left join {sc}.device_exposure dev on cost_domain_id = 'Device' and cost_event_id = dev.device_exposure_id | ||
left join {sc}.measurement m on cost_domain_id = 'Measurement' and cost_event_id = m.measurement_id | ||
left join {sc}.visit_occurrence v on cost_domain_id = 'Visit' and cost_event_id = v.visit_occurrence_id | ||
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND coalesce(po.person_id, o.person_id, d.person_id, dev.person_id, m.person_id, v.person_id) = ch.PERSON_ID | ||
order by 1 | ||
</Query> | ||
<Costs> | ||
<CostRawDefinition> | ||
<PersonId>person_id</PersonId> | ||
|
||
<Id>cost_id</Id> | ||
<EventId>cost_event_id</EventId> | ||
<DomainId>cost_domain_id</DomainId> | ||
<TypeConceptId>cost_type_concept_id</TypeConceptId> | ||
<CurrencyConceptId>currency_concept_id</CurrencyConceptId> | ||
<TotalCharge>total_charge</TotalCharge> | ||
<TotalCost>total_cost</TotalCost> | ||
<TotalPaid>total_paid</TotalPaid> | ||
|
||
<PaidByPayer>paid_by_payer</PaidByPayer> | ||
<PaidByPatient>paid_by_patient</PaidByPatient> | ||
<PaidPatientCopay>paid_patient_copay</PaidPatientCopay> | ||
<PaidPatientCoinsurance>paid_patient_coinsurance</PaidPatientCoinsurance> | ||
<PaidPatientDeductible>paid_patient_deductible</PaidPatientDeductible> | ||
<PaidIngredientCost>paid_ingredient_cost</PaidIngredientCost> | ||
<PaidDispensingFee>paid_dispensing_fee</PaidDispensingFee> | ||
|
||
<PayerPlanPeriodId>payer_plan_period_id</PayerPlanPeriodId> | ||
|
||
<AmountAllowed>amount_allowed</AmountAllowed> | ||
|
||
<RevenueCodeConceptId>revenue_code_concept_id</RevenueCodeConceptId> | ||
<RevenueCodeSourceValue>revenue_code_source_value</RevenueCodeSourceValue> | ||
|
||
<DrgConceptId>drg_concept_id</DrgConceptId> | ||
<DrgSourceValue>drg_source_value</DrgSourceValue> | ||
</CostRawDefinition> | ||
</Costs> | ||
</QueryDefinition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/CostRawDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using org.ohdsi.cdm.framework.common.Builder; | ||
using org.ohdsi.cdm.framework.common.Extensions; | ||
using org.ohdsi.cdm.framework.common.Omop; | ||
using System.Data; | ||
|
||
namespace org.ohdsi.cdm.framework.common.Definitions | ||
{ | ||
public class CostRawDefinition : EntityDefinition | ||
{ | ||
public string TypeConceptId { get; set; } | ||
|
||
public string EventId { get; set; } | ||
public string DomainId { get; set; } | ||
public string CurrencyConceptId { get; set; } | ||
public string TotalCharge { get; set; } | ||
public string TotalCost { get; set; } | ||
public string TotalPaid { get; set; } | ||
|
||
|
||
public string PaidByPayer { get; set; } | ||
public string PaidByPatient { get; set; } | ||
public string PaidPatientCopay { get; set; } | ||
public string PaidPatientCoinsurance { get; set; } | ||
public string PaidPatientDeductible { get; set; } | ||
public string PaidIngredientCost { get; set; } | ||
public string PaidDispensingFee { get; set; } | ||
|
||
public string PayerPlanPeriodId { get; set; } | ||
|
||
public string AmountAllowed { get; set; } | ||
|
||
public string RevenueCodeConceptId { get; set; } | ||
public string RevenueCodeSourceValue { get; set; } | ||
|
||
public string DrgConceptId { get; set; } | ||
public string DrgSourceValue { get; set; } | ||
|
||
|
||
public IEnumerable<Cost> GetCost(Concept concept, IDataRecord reader, | ||
KeyMasterOffsetManager offset) | ||
{ | ||
var presonId = reader.GetLong(PersonId); | ||
yield return new Cost(presonId.Value) | ||
{ | ||
Id = reader.GetLong(Id), | ||
|
||
PersonId = presonId.Value, | ||
TypeId = reader.GetLong(TypeConceptId), | ||
|
||
EventId = reader.GetLong(EventId) ?? 0, | ||
Domain = reader.GetString(DomainId), | ||
CurrencyConceptId = reader.GetLong(CurrencyConceptId) ?? 0, | ||
TotalCharge = reader.GetDecimal(TotalCharge), | ||
TotalCost = reader.GetDecimal(TotalCost), | ||
TotalPaid = reader.GetDecimal(TotalPaid), | ||
|
||
PaidByPayer = reader.GetDecimal(PaidByPayer), | ||
PaidByPatient = reader.GetDecimal(PaidByPatient), | ||
PaidPatientCopay = reader.GetDecimal(PaidPatientCopay), | ||
PaidPatientCoinsurance = reader.GetDecimal(PaidPatientCoinsurance), | ||
PaidPatientDeductible = reader.GetDecimal(PaidPatientDeductible), | ||
PaidIngredientCost = reader.GetDecimal(PaidIngredientCost), | ||
PaidDispensingFee = reader.GetDecimal(PaidDispensingFee), | ||
|
||
PayerPlanPeriodId = reader.GetLong(PayerPlanPeriodId), | ||
|
||
AmountAllowed = reader.GetDecimal(AmountAllowed), | ||
|
||
RevenueCodeConceptId = reader.GetLong(RevenueCodeConceptId), | ||
RevenueCodeSourceValue = reader.GetString(RevenueCodeSourceValue), | ||
|
||
DrgConceptId = reader.GetLong(DrgConceptId), | ||
DrgSourceValue = reader.GetString(DrgSourceValue) | ||
}; | ||
} | ||
|
||
public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffsetManager offset) | ||
{ | ||
throw new NotImplementedException("CostDefinitionRaw.GetConcepts()"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters