Search in sources :

Example 1 with Extension

use of org.hl7.fhir.dstu2016may.model.Extension 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 Extension

use of org.hl7.fhir.dstu2016may.model.Extension 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 Extension

use of org.hl7.fhir.dstu2016may.model.Extension 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 4 with Extension

use of org.hl7.fhir.dstu2016may.model.Extension 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)

Example 5 with Extension

use of org.hl7.fhir.dstu2016may.model.Extension in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method addExtensionValueQuantity.

/**
 * Adds an {@link Extension} to the specified {@link DomainResource}. {@link Extension#getValue()}
 * will be set to a {@link Quantity} with the specified system and value.
 *
 * @param fhirElement the FHIR element to add the {@link Extension} to
 * @param extensionUrl the {@link Extension#getUrl()} to use
 * @param quantitySystem the {@link Quantity#getSystem()} to use
 * @param quantityValue the {@link Quantity#getValue()} to use
 */
static void addExtensionValueQuantity(IBaseHasExtensions fhirElement, String extensionUrl, String quantitySystem, BigDecimal quantityValue) {
    IBaseExtension<?, ?> extension = fhirElement.addExtension();
    extension.setUrl(extensionUrl);
    extension.setValue(new Quantity().setSystem(extensionUrl).setValue(quantityValue));
// CodeableConcept codeableConcept = new CodeableConcept();
// extension.setValue(codeableConcept);
// 
// Coding coding = codeableConcept.addCoding();
// coding.setSystem(codingSystem).setCode(codingCode);
}
Also used : SimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity) Quantity(org.hl7.fhir.dstu3.model.Quantity)

Aggregations

Extension (org.hl7.fhir.r4.model.Extension)154 ArrayList (java.util.ArrayList)104 Coding (org.hl7.fhir.r4.model.Coding)69 Test (org.junit.jupiter.api.Test)69 Extension (org.hl7.fhir.dstu3.model.Extension)67 FHIRException (org.hl7.fhir.exceptions.FHIRException)55 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)46 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)42 Extension (org.hl7.fhir.r5.model.Extension)41 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)39 Test (org.junit.Test)36 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)35 List (java.util.List)34 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)34 Date (java.util.Date)30 Coding (org.hl7.fhir.dstu3.model.Coding)29 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)27 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)27 Reference (org.hl7.fhir.dstu3.model.Reference)26 Patient (org.hl7.fhir.r4.model.Patient)26