org.hl7.fhir.instance.model.api.IAnyResource Java Examples

The following examples show how to use org.hl7.fhir.instance.model.api.IAnyResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FhirModelResolver.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
protected BaseRuntimeElementCompositeDefinition<?> resolveRuntimeDefinition(IBase base) {
    if (base instanceof IAnyResource) {
        return getFhirContext().getResourceDefinition((IAnyResource) base);
    }

    else if (base instanceof IBaseBackboneElement || base instanceof IBaseElement) {
        return (BaseRuntimeElementCompositeDefinition<?>) getFhirContext().getElementDefinition(base.getClass());
    }

    else if (base instanceof ICompositeType) {
        return (BaseRuntimeElementCompositeDefinition<ICompositeType>) getFhirContext().getElementDefinition(base.getClass());
    }

    throw new UnknownType(String.format("Unable to resolve the runtime definition for %s", base.getClass().getName()));
}
 
Example #2
Source File: MeasureOperationsProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
@Operation(name = "$submit-data", idempotent = true, type = Measure.class)
public Resource submitData(RequestDetails details, @IdParam IdType theId,
        @OperationParam(name = "measure-report", min = 1, max = 1, type = MeasureReport.class) MeasureReport report,
        @OperationParam(name = "resource") List<IAnyResource> resources) {
    Bundle transactionBundle = new Bundle().setType(Bundle.BundleType.TRANSACTION);

    /*
     * TODO - resource validation using $data-requirements operation (params are the
     * provided id and the measurement period from the MeasureReport)
     * 
     * TODO - profile validation ... not sure how that would work ... (get
     * StructureDefinition from URL or must it be stored in Ruler?)
     */

    transactionBundle.addEntry(createTransactionEntry(report));

    for (IAnyResource resource : resources) {
        Resource res = (Resource) resource;
        if (res instanceof Bundle) {
            for (Bundle.BundleEntryComponent entry : createTransactionBundle((Bundle) res).getEntry()) {
                transactionBundle.addEntry(entry);
            }
        } else {
            // Build transaction bundle
            transactionBundle.addEntry(createTransactionEntry(res));
        }
    }

    return (Resource) this.registry.getSystemDao().transaction(details, transactionBundle);
}
 
Example #3
Source File: MeasureOperationsProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
@Operation(name = "$submit-data", idempotent = true, type = Measure.class)
public Resource submitData(RequestDetails details, @IdParam IdType theId,
        @OperationParam(name = "measure-report", min = 1, max = 1, type = MeasureReport.class) MeasureReport report,
        @OperationParam(name = "resource") List<IAnyResource> resources) {
    Bundle transactionBundle = new Bundle().setType(Bundle.BundleType.TRANSACTION);

    /*
     * TODO - resource validation using $data-requirements operation (params are the
     * provided id and the measurement period from the MeasureReport)
     * 
     * TODO - profile validation ... not sure how that would work ... (get
     * StructureDefinition from URL or must it be stored in Ruler?)
     */

    transactionBundle.addEntry(createTransactionEntry(report));

    for (IAnyResource resource : resources) {
        Resource res = (Resource) resource;
        if (res instanceof Bundle) {
            for (Bundle.BundleEntryComponent entry : createTransactionBundle((Bundle) res).getEntry()) {
                transactionBundle.addEntry(entry);
            }
        } else {
            // Build transaction bundle
            transactionBundle.addEntry(createTransactionEntry(res));
        }
    }

    return (Resource) this.registry.getSystemDao().transaction(details, transactionBundle);
}
 
Example #4
Source File: BaseReference.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public BaseReference(IAnyResource theResource) {
	resource = theResource;
}
 
Example #5
Source File: BaseReference.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public BaseReference(IAnyResource theResource) {
	resource = theResource;
}
 
Example #6
Source File: BaseReference.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public BaseReference(IAnyResource theResource) {
	resource = theResource;
}
 
Example #7
Source File: BaseReference.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public BaseReference(IAnyResource theResource) {
	resource = theResource;
}
 
Example #8
Source File: BaseReference.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public BaseReference(IAnyResource theResource) {
	resource = theResource;
}
 
Example #9
Source File: FhirModelResolver.java    From cql_engine with Apache License 2.0 4 votes vote down vote up
protected Object resolveProperty(Object target, String path) {
    if (target == null) {
        return null;
    }

    if (target instanceof IBaseEnumeration && path.equals("value")) {
        return ((IBaseEnumeration) target).getValueAsString();
    }


    // TODO: Consider using getResourceType everywhere?
    if (target instanceof IAnyResource && this.getResourceType((ResourceType) target).equals(path)) {
        return target;
    }

    IBase base = (IBase) target;
    BaseRuntimeElementCompositeDefinition<?> definition;
    if (base instanceof IPrimitiveType) {
        return toJavaPrimitive(path.equals("value") ? ((IPrimitiveType<?>) target).getValue() : target, base);
    }
    else {
        definition = resolveRuntimeDefinition(base);
    }

    BaseRuntimeChildDefinition child = definition.getChildByName(path);
    if (child == null) {
        child = resolveChoiceProperty(definition, path);
    }

    if (child == null) {
        return null;
    }

    List<IBase> values = child.getAccessor().getValues(base);

    if (values == null || values.isEmpty()) {
        return null;
    }

    if (child instanceof RuntimeChildChoiceDefinition && !child.getElementName().equalsIgnoreCase(path)) {
        if (!values.get(0).getClass().getSimpleName().equalsIgnoreCase(child.getChildByName(path).getImplementingClass().getSimpleName()))
        {
            return null;
        }
    }

    return toJavaPrimitive(child.getMax() < 1 ? values : values.get(0), base);
}
 
Example #10
Source File: Reference.java    From org.hl7.fhir.core with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor
 * 
 * @param theResource The resource represented by this reference
 */
public Reference(IAnyResource theResource) {
  super(theResource);
}
 
Example #11
Source File: Reference.java    From org.hl7.fhir.core with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor
 * 
 * @param theResource The resource represented by this reference
 */
public Reference(IAnyResource theResource) {
  super(theResource);
}
 
Example #12
Source File: Reference.java    From org.hl7.fhir.core with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor
 * 
 * @param theResource The resource represented by this reference
 */
public Reference(IAnyResource theResource) {
  super(theResource);
}
 
Example #13
Source File: Reference.java    From org.hl7.fhir.core with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor
 * 
 * @param theResource The resource represented by this reference
 */
public Reference(IAnyResource theResource) {
  super(theResource);
}