Search in sources :

Example 11 with IAnyResource

use of org.hl7.fhir.instance.model.api.IAnyResource in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsV2 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 : Extension(org.hl7.fhir.r4.model.Extension) Coding(org.hl7.fhir.r4.model.Coding)

Example 12 with IAnyResource

use of org.hl7.fhir.instance.model.api.IAnyResource in project quality-measure-and-cohort-service by Alvearie.

the class CohortCLI method prettyPrintValue.

private String prettyPrintValue(Object value) {
    String retVal;
    if (value != null) {
        if (value instanceof IAnyResource) {
            IAnyResource resource = (IAnyResource) value;
            retVal = resource.getId();
        } else if (value instanceof Collection) {
            Collection<?> collection = (Collection<?>) value;
            retVal = "Collection: " + collection.size();
        } else {
            retVal = value.toString();
        }
    } else {
        retVal = "null";
    }
    return retVal;
}
Also used : IAnyResource(org.hl7.fhir.instance.model.api.IAnyResource) Collection(java.util.Collection)

Aggregations

Coding (org.hl7.fhir.dstu3.model.Coding)4 Coding (org.hl7.fhir.r4.model.Coding)4 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)3 IAnyResource (org.hl7.fhir.instance.model.api.IAnyResource)3 IBaseExtension (org.hl7.fhir.instance.model.api.IBaseExtension)3 Extension (org.hl7.fhir.dstu3.model.Extension)2 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 Extension (org.hl7.fhir.r4.model.Extension)2 BaseRuntimeChildDefinition (ca.uhn.fhir.context.BaseRuntimeChildDefinition)1 BaseRuntimeElementCompositeDefinition (ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition)1 BaseRuntimeElementDefinition (ca.uhn.fhir.context.BaseRuntimeElementDefinition)1 RuntimeElemContainedResourceList (ca.uhn.fhir.context.RuntimeElemContainedResourceList)1 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)1 Collection (java.util.Collection)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1