Search in sources :

Example 1 with BadCodeMonkeyException

use of gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method createExtensionQuantity.

/**
 * @param ccwVariable the {@link CcwCodebookInterface} being mapped
 * @param quantityValue the value to use for {@link Coding#getCode()} for the resulting {@link
 *     Coding}
 * @return the output {@link Extension}, with {@link Extension#getValue()} set to represent the
 *     specified input values
 */
static Extension createExtensionQuantity(CcwCodebookInterface ccwVariable, Optional<? extends Number> quantityValue) {
    if (!quantityValue.isPresent())
        throw new IllegalArgumentException();
    Quantity quantity;
    if (quantityValue.get() instanceof BigDecimal)
        quantity = new Quantity().setValue((BigDecimal) quantityValue.get());
    else
        throw new BadCodeMonkeyException();
    String extensionUrl = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
    Extension extension = new Extension(extensionUrl, quantity);
    return extension;
}
Also used : IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) Extension(org.hl7.fhir.dstu3.model.Extension) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) SimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity) Quantity(org.hl7.fhir.dstu3.model.Quantity) BigDecimal(java.math.BigDecimal)

Example 2 with BadCodeMonkeyException

use of gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method createMoney.

/**
 * @param amountValue the value to use for {@link Money#getValue()}
 * @return a new {@link Money} instance, with the specified {@link Money#getValue()}
 */
static Money createMoney(Optional<? extends Number> amountValue) {
    if (!amountValue.isPresent())
        throw new IllegalArgumentException();
    Money money = new Money();
    money.setSystem(TransformerConstants.CODING_MONEY);
    money.setCode(TransformerConstants.CODED_MONEY_USD);
    if (amountValue.get() instanceof BigDecimal)
        money.setValue((BigDecimal) amountValue.get());
    else
        throw new BadCodeMonkeyException();
    return money;
}
Also used : Money(org.hl7.fhir.dstu3.model.Money) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) BigDecimal(java.math.BigDecimal)

Example 3 with BadCodeMonkeyException

use of gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException in project beneficiary-fhir-data by CMSgov.

the class HospiceClaimTransformer method transform.

/**
 * @param metricRegistry the {@link MetricRegistry} to use
 * @param claim the CCW {@link HospiceClaim} to transform
 * @param includeTaxNumbers whether or not to include tax numbers in the result (see {@link
 *     ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS}, defaults to <code>
 *     false</code>)
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     HospiceClaim}
 */
@Trace
static ExplanationOfBenefit transform(MetricRegistry metricRegistry, Object claim, Optional<Boolean> includeTaxNumbers) {
    Timer.Context timer = metricRegistry.timer(MetricRegistry.name(HospiceClaimTransformer.class.getSimpleName(), "transform")).time();
    if (!(claim instanceof HospiceClaim))
        throw new BadCodeMonkeyException();
    ExplanationOfBenefit eob = transformClaim((HospiceClaim) claim);
    timer.stop();
    return eob;
}
Also used : Timer(com.codahale.metrics.Timer) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Trace(com.newrelic.api.agent.Trace)

Example 4 with BadCodeMonkeyException

use of gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException in project beneficiary-fhir-data by CMSgov.

the class InpatientClaimTransformer method transform.

/**
 * @param metricRegistry the {@link MetricRegistry} to use
 * @param claim the CCW {@link InpatientClaim} to transform
 * @param includeTaxNumbers whether or not to include tax numbers in the result (see {@link
 *     ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS}, defaults to <code>
 *     false</code>)
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     InpatientClaim}
 */
@Trace
static ExplanationOfBenefit transform(MetricRegistry metricRegistry, Object claim, Optional<Boolean> includeTaxNumbers) {
    Timer.Context timer = metricRegistry.timer(MetricRegistry.name(InpatientClaimTransformer.class.getSimpleName(), "transform")).time();
    if (!(claim instanceof InpatientClaim))
        throw new BadCodeMonkeyException();
    ExplanationOfBenefit eob = transformClaim((InpatientClaim) claim);
    timer.stop();
    return eob;
}
Also used : InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) Timer(com.codahale.metrics.Timer) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Trace(com.newrelic.api.agent.Trace)

Example 5 with BadCodeMonkeyException

use of gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsV2 method createExtensionQuantity.

/**
 * @param ccwVariable the {@link CcwCodebookInterface} being mapped
 * @param quantityValue the value to use for {@link Coding#getCode()} for the resulting {@link
 *     Coding}
 * @return the output {@link Extension}, with {@link Extension#getValue()} set to represent the
 *     specified input values
 */
static Extension createExtensionQuantity(CcwCodebookInterface ccwVariable, Optional<? extends Number> quantityValue) {
    if (!quantityValue.isPresent()) {
        throw new IllegalArgumentException();
    }
    Quantity quantity;
    if (quantityValue.get() instanceof BigDecimal) {
        quantity = new Quantity().setValue((BigDecimal) quantityValue.get());
    } else {
        throw new BadCodeMonkeyException();
    }
    String extensionUrl = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
    Extension extension = new Extension(extensionUrl, quantity);
    return extension;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Quantity(org.hl7.fhir.r4.model.Quantity) BigDecimal(java.math.BigDecimal)

Aggregations

BadCodeMonkeyException (gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException)52 Timer (com.codahale.metrics.Timer)18 Trace (com.newrelic.api.agent.Trace)15 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)14 IOException (java.io.IOException)11 CarrierClaim (gov.cms.bfd.model.rif.CarrierClaim)10 DMEClaim (gov.cms.bfd.model.rif.DMEClaim)9 HHAClaim (gov.cms.bfd.model.rif.HHAClaim)9 HospiceClaim (gov.cms.bfd.model.rif.HospiceClaim)9 InpatientClaim (gov.cms.bfd.model.rif.InpatientClaim)9 OutpatientClaim (gov.cms.bfd.model.rif.OutpatientClaim)9 BigDecimal (java.math.BigDecimal)9 LocalDate (java.time.LocalDate)9 TemporalPrecisionEnum (ca.uhn.fhir.model.api.TemporalPrecisionEnum)8 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)8 CcwCodebookInterface (gov.cms.bfd.model.codebook.model.CcwCodebookInterface)8 FhirContext (ca.uhn.fhir.context.FhirContext)7 CarrierClaimColumn (gov.cms.bfd.model.rif.CarrierClaimColumn)7 CarrierClaimLine (gov.cms.bfd.model.rif.CarrierClaimLine)7 DMEClaimColumn (gov.cms.bfd.model.rif.DMEClaimColumn)7