use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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);
}
Aggregations