Search in sources :

Example 1 with Value

use of org.hl7.fhir.utilities.graphql.Value 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 Value

use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method createExtensionDate.

/**
 * @param ccwVariable the {@link CcwCodebookInterface} being mapped
 * @param dateYear 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 createExtensionDate(CcwCodebookInterface ccwVariable, Optional<BigDecimal> dateYear) {
    Extension extension = null;
    if (!dateYear.isPresent()) {
        throw new NoSuchElementException();
    }
    try {
        String stringDate = String.format("%04d", dateYear.get().intValue());
        DateType dateYearValue = new DateType(stringDate);
        String extensionUrl = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
        extension = new Extension(extensionUrl, dateYearValue);
    } catch (DataFormatException e) {
        throw new InvalidRifValueException(String.format("Unable to create DateType with reference year: '%s'.", dateYear.get()), e);
    }
    return extension;
}
Also used : IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) Extension(org.hl7.fhir.dstu3.model.Extension) DataFormatException(ca.uhn.fhir.parser.DataFormatException) InvalidRifValueException(gov.cms.bfd.model.rif.parse.InvalidRifValueException) DateType(org.hl7.fhir.dstu3.model.DateType) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with Value

use of org.hl7.fhir.utilities.graphql.Value 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 4 with Value

use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method createExtensionCoding.

/**
 * @param rootResource the root FHIR {@link IAnyResource} that the resultant {@link Extension}
 *     will be contained in
 * @param ccwVariable the {@link CcwCodebookInterface} being coded
 * @param code the value to use for {@link Coding#getCode()} for the resulting {@link Coding}
 * @return the output {@link Extension}, with {@link Extension#getValue()} set to a new {@link
 *     Coding} to represent the specified input values
 */
static Extension createExtensionCoding(IAnyResource rootResource, CcwCodebookInterface ccwVariable, Optional<?> code) {
    if (!code.isPresent())
        throw new IllegalArgumentException();
    Coding coding = createCoding(rootResource, ccwVariable, code.get());
    String extensionUrl = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
    Extension extension = new Extension(extensionUrl, coding);
    return extension;
}
Also used : IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) Extension(org.hl7.fhir.dstu3.model.Extension) Coding(org.hl7.fhir.dstu3.model.Coding)

Example 5 with Value

use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method createExtensionCoding.

/**
 * @param rootResource the root FHIR {@link IAnyResource} that the resultant {@link Extension}
 *     will be contained in
 * @param ccwVariable the {@link CcwCodebookInterface being coded
 * @param code the value to use for {@link Coding#getCode()} for the resulting {@link Coding}
 * @return the output {@link Extension}, with {@link Extension#getValue()} set to a new {@link
 *     Coding} to represent the specified input values
 */
static Extension createExtensionCoding(IAnyResource rootResource, CcwCodebookInterface ccwVariable, String yearMonth, Optional<?> code) {
    if (!code.isPresent())
        throw new IllegalArgumentException();
    Coding coding = createCoding(rootResource, ccwVariable, yearMonth, code.get());
    String extensionUrl = String.format("%s/%s", CCWUtils.calculateVariableReferenceUrl(ccwVariable), yearMonth);
    Extension extension = new Extension(extensionUrl, coding);
    return extension;
}
Also used : IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) Extension(org.hl7.fhir.dstu3.model.Extension) Coding(org.hl7.fhir.dstu3.model.Coding)

Aggregations

Test (org.junit.jupiter.api.Test)222 ArrayList (java.util.ArrayList)183 FHIRException (org.hl7.fhir.exceptions.FHIRException)107 List (java.util.List)97 DisplayName (org.junit.jupiter.api.DisplayName)96 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)89 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)85 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)70 Identifier (org.hl7.fhir.r4.model.Identifier)69 Test (org.junit.Test)66 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)64 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)54 IOException (java.io.IOException)52 Bundle (org.hl7.fhir.r4.model.Bundle)49 Coding (org.hl7.fhir.r4.model.Coding)49 ValueSet (org.hl7.fhir.r5.model.ValueSet)48 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)46 Resource (org.hl7.fhir.r4.model.Resource)46 BigDecimal (java.math.BigDecimal)45 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)44