use of org.hl7.fhir.dstu2016may.model.DecimalType in project clinical_quality_language by cqframework.
the class DataRequirementsProcessor method toFhirValue.
private DataType toFhirValue(ElmRequirementsContext context, Expression value) {
if (value == null) {
return null;
}
if (value instanceof Interval) {
// TODO: Handle lowclosed/highclosed
return new Period().setStartElement(toFhirDateTimeValue(context, ((Interval) value).getLow())).setEndElement(toFhirDateTimeValue(context, ((Interval) value).getHigh()));
} else if (value instanceof Literal) {
if (context.getTypeResolver().isDateTimeType(value.getResultType())) {
return new DateTimeType(((Literal) value).getValue());
} else if (context.getTypeResolver().isDateType(value.getResultType())) {
return new DateType(((Literal) value).getValue());
} else if (context.getTypeResolver().isIntegerType(value.getResultType())) {
return new IntegerType(((Literal) value).getValue());
} else if (context.getTypeResolver().isDecimalType(value.getResultType())) {
return new DecimalType(((Literal) value).getValue());
} else if (context.getTypeResolver().isStringType(value.getResultType())) {
return new StringType(((Literal) value).getValue());
}
} else if (value instanceof DateTime) {
DateTime dateTime = (DateTime) value;
return new DateTimeType(toDateTimeString(toFhirValue(context, dateTime.getYear()), toFhirValue(context, dateTime.getMonth()), toFhirValue(context, dateTime.getDay()), toFhirValue(context, dateTime.getHour()), toFhirValue(context, dateTime.getMinute()), toFhirValue(context, dateTime.getSecond()), toFhirValue(context, dateTime.getMillisecond()), toFhirValue(context, dateTime.getTimezoneOffset())));
} else if (value instanceof org.hl7.elm.r1.Date) {
org.hl7.elm.r1.Date date = (org.hl7.elm.r1.Date) value;
return new DateType(toDateString(toFhirValue(context, date.getYear()), toFhirValue(context, date.getMonth()), toFhirValue(context, date.getDay())));
} else if (value instanceof Start) {
DataType operand = toFhirValue(context, ((Start) value).getOperand());
if (operand != null) {
Period period = (Period) operand;
return period.getStartElement();
}
} else if (value instanceof End) {
DataType operand = toFhirValue(context, ((End) value).getOperand());
if (operand != null) {
Period period = (Period) operand;
return period.getEndElement();
}
} else if (value instanceof ParameterRef) {
if (context.getTypeResolver().isIntervalType(value.getResultType())) {
Extension e = toExpression(context, (ParameterRef) value);
org.hl7.cql.model.DataType pointType = ((IntervalType) value.getResultType()).getPointType();
if (context.getTypeResolver().isDateTimeType(pointType) || context.getTypeResolver().isDateType(pointType)) {
Period period = new Period();
period.addExtension(e);
return period;
} else if (context.getTypeResolver().isQuantityType(pointType) || context.getTypeResolver().isIntegerType(pointType) || context.getTypeResolver().isDecimalType(pointType)) {
Range range = new Range();
range.addExtension(e);
return range;
} else {
throw new IllegalArgumentException(String.format("toFhirValue not implemented for interval of %s", pointType.toString()));
}
} else // Boolean, Integer, Decimal, String, Quantity, Date, DateTime, Time, Coding, CodeableConcept
if (context.getTypeResolver().isBooleanType(value.getResultType())) {
BooleanType result = new BooleanType();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else if (context.getTypeResolver().isIntegerType(value.getResultType())) {
IntegerType result = new IntegerType();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else if (context.getTypeResolver().isDecimalType(value.getResultType())) {
DecimalType result = new DecimalType();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else if (context.getTypeResolver().isQuantityType(value.getResultType())) {
Quantity result = new Quantity();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else if (context.getTypeResolver().isCodeType(value.getResultType())) {
Coding result = new Coding();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else if (context.getTypeResolver().isConceptType(value.getResultType())) {
CodeableConcept result = new CodeableConcept();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else if (context.getTypeResolver().isDateType(value.getResultType())) {
DateType result = new DateType();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else if (context.getTypeResolver().isDateTimeType(value.getResultType())) {
DateTimeType result = new DateTimeType();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else if (context.getTypeResolver().isTimeType(value.getResultType())) {
TimeType result = new TimeType();
result.addExtension(toExpression(context, (ParameterRef) value));
return result;
} else {
throw new IllegalArgumentException(String.format("toFhirValue not implemented for parameter of type %s", value.getResultType().toString()));
}
}
throw new IllegalArgumentException(String.format("toFhirValue not implemented for %s", value.getClass().getSimpleName()));
}
use of org.hl7.fhir.dstu2016may.model.DecimalType in project beneficiary-fhir-data by CMSgov.
the class HHAClaimTransformerV2Test method shouldHavePrpayAmtFinancial.
@Test
public void shouldHavePrpayAmtFinancial() {
BenefitComponent benefit = TransformerTestUtilsV2.findFinancial("https://bluebutton.cms.gov/resources/variables/prpayamt", eob.getBenefitBalanceFirstRep().getFinancial());
BenefitComponent compare = new BenefitComponent().setType(new CodeableConcept().setCoding(Arrays.asList(new Coding("https://bluebutton.cms.gov/resources/codesystem/benefit-balance", "https://bluebutton.cms.gov/resources/variables/prpayamt", "NCH Primary Payer (if not Medicare) Claim Paid Amount")))).setUsed(new Money().setValueElement(new DecimalType("11.00")).setCurrency(TransformerConstants.CODED_MONEY_USD));
assertTrue(compare.equalsDeep(benefit));
}
use of org.hl7.fhir.dstu2016may.model.DecimalType in project beneficiary-fhir-data by CMSgov.
the class CarrierClaimTransformerV2Test method shouldHaveClmPassThruCashDeductibleFinancial.
@Test
public void shouldHaveClmPassThruCashDeductibleFinancial() {
BenefitComponent benefit = TransformerTestUtilsV2.findFinancial("https://bluebutton.cms.gov/resources/variables/carr_clm_cash_ddctbl_apld_amt", eob.getBenefitBalanceFirstRep().getFinancial());
BenefitComponent compare = new BenefitComponent().setType(new CodeableConcept().setCoding(Arrays.asList(new Coding("https://bluebutton.cms.gov/resources/codesystem/benefit-balance", "https://bluebutton.cms.gov/resources/variables/carr_clm_cash_ddctbl_apld_amt", "Carrier Claim Cash Deductible Applied Amount (sum of all line-level deductible amounts)")))).setUsed(new Money().setValueElement(new DecimalType("777.00")).setCurrency(TransformerConstants.CODED_MONEY_USD));
assertTrue(compare.equalsDeep(benefit));
}
use of org.hl7.fhir.dstu2016may.model.DecimalType in project beneficiary-fhir-data by CMSgov.
the class CarrierClaimTransformerV2Test method shouldHaveClmPassThruClaimProviderPaymentAmountFinancial.
@Test
public void shouldHaveClmPassThruClaimProviderPaymentAmountFinancial() {
BenefitComponent benefit = TransformerTestUtilsV2.findFinancial("https://bluebutton.cms.gov/resources/variables/nch_clm_prvdr_pmt_amt", eob.getBenefitBalanceFirstRep().getFinancial());
BenefitComponent compare = new BenefitComponent().setType(new CodeableConcept().setCoding(Arrays.asList(new Coding("https://bluebutton.cms.gov/resources/codesystem/benefit-balance", "https://bluebutton.cms.gov/resources/variables/nch_clm_prvdr_pmt_amt", "NCH Claim Provider Payment Amount")))).setUsed(new Money().setValueElement(new DecimalType("123.45")).setCurrency(TransformerConstants.CODED_MONEY_USD));
assertTrue(compare.equalsDeep(benefit));
}
use of org.hl7.fhir.dstu2016may.model.DecimalType in project beneficiary-fhir-data by CMSgov.
the class CarrierClaimTransformerV2Test method shouldHaveClmPassThruClaimProviderPaymentAmountToBeneficiaryFinancial.
@Test
public void shouldHaveClmPassThruClaimProviderPaymentAmountToBeneficiaryFinancial() {
BenefitComponent benefit = TransformerTestUtilsV2.findFinancial("https://bluebutton.cms.gov/resources/variables/nch_clm_bene_pmt_amt", eob.getBenefitBalanceFirstRep().getFinancial());
BenefitComponent compare = new BenefitComponent().setType(new CodeableConcept().setCoding(Arrays.asList(new Coding("https://bluebutton.cms.gov/resources/codesystem/benefit-balance", "https://bluebutton.cms.gov/resources/variables/nch_clm_bene_pmt_amt", "NCH Claim Payment Amount to Beneficiary")))).setUsed(new Money().setValueElement(new DecimalType("888.00")).setCurrency(TransformerConstants.CODED_MONEY_USD));
assertTrue(compare.equalsDeep(benefit));
}
Aggregations