org.hl7.fhir.dstu3.model.Parameters Java Examples
The following examples show how to use
org.hl7.fhir.dstu3.model.Parameters.
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: BaseWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") private String describeValidationParameters(Parameters pin) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); for (ParametersParameterComponent p : pin.getParameter()) { if (p.hasValue() && p.getValue() instanceof PrimitiveType) { b.append(p.getName() + "=" + ((PrimitiveType) p.getValue()).asStringValue()); } else if (p.hasValue() && p.getValue() instanceof Coding) { b.append("system=" + ((Coding) p.getValue()).getSystem()); b.append("code=" + ((Coding) p.getValue()).getCode()); b.append("display=" + ((Coding) p.getValue()).getDisplay()); } else if (p.hasValue() && p.getValue() instanceof CodeableConcept) { if (((CodeableConcept) p.getValue()).hasCoding()) { Coding c = ((CodeableConcept) p.getValue()).getCodingFirstRep(); b.append("system=" + c.getSystem()); b.append("code=" + c.getCode()); b.append("display=" + c.getDisplay()); } else if (((CodeableConcept) p.getValue()).hasText()) { b.append("text=" + ((CodeableConcept) p.getValue()).getText()); } } else if (p.hasResource() && (p.getResource() instanceof ValueSet)) { b.append("valueset=" + getVSSummary((ValueSet) p.getResource())); } } return b.toString(); }
Example #2
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 6 votes |
private void resolveReferences(Resource resource, Parameters parameters, Map<String, Resource> resourceMap) { List<IBase> values; for (BaseRuntimeChildDefinition child : this.measureResourceProvider.getContext().getResourceDefinition(resource).getChildren()) { values = child.getAccessor().getValues(resource); if (values == null || values.isEmpty()) { continue; } else if (values.get(0) instanceof Reference && ((Reference) values.get(0)).getReferenceElement().hasResourceType() && ((Reference) values.get(0)).getReferenceElement().hasIdPart()) { Resource fetchedResource = (Resource) registry .getResourceDao(((Reference) values.get(0)).getReferenceElement().getResourceType()) .read(new IdType(((Reference) values.get(0)).getReferenceElement().getIdPart())); if (!resourceMap.containsKey(fetchedResource.getIdElement().getValue())) { parameters.addParameter(new Parameters.ParametersParameterComponent().setName("resource") .setResource(fetchedResource)); resourceMap.put(fetchedResource.getIdElement().getValue(), fetchedResource); } } } }
Example #3
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 6 votes |
private void addEvaluatedResourcesToParameters(Bundle contained, Parameters parameters) { Map<String, Resource> resourceMap = new HashMap<>(); if (contained.hasEntry()) { for (Bundle.BundleEntryComponent entry : contained.getEntry()) { if (entry.hasResource() && !(entry.getResource() instanceof ListResource)) { if (!resourceMap.containsKey(entry.getResource().getIdElement().getValue())) { parameters.addParameter(new Parameters.ParametersParameterComponent().setName("resource") .setResource(entry.getResource())); resourceMap.put(entry.getResource().getIdElement().getValue(), entry.getResource()); resolveReferences(entry.getResource(), parameters, resourceMap); } } } } }
Example #4
Source File: LibraryOperationsProvider.java From cqf-ruler with Apache License 2.0 | 6 votes |
@Operation(name = "$get-elm", idempotent = true, type = Library.class) public Parameters getElm(@IdParam IdType theId, @OptionalParam(name="format") String format) { Library theResource = this.libraryResourceProvider.getDao().read(theId); // this.formatCql(theResource); ModelManager modelManager = this.getModelManager(); LibraryManager libraryManager = this.getLibraryManager(modelManager); String elm = ""; CqlTranslator translator = this.dataRequirementsProvider.getTranslator(theResource, libraryManager, modelManager); if (translator != null) { if (format.equals("json")) { elm = translator.toJson(); } else { elm = translator.toXml(); } } Parameters p = new Parameters(); p.addParameter().setValue(new StringType(elm)); return p; }
Example #5
Source File: TranslationResults.java From careconnect-reference-implementation with Apache License 2.0 | 6 votes |
public Parameters toParameters() { Parameters retVal = new Parameters(); if (myResult != null) { retVal.addParameter().setName("result").setValue(myResult); } if (myMessage != null) { retVal.addParameter().setName("message").setValue(myMessage); } for (TranslationMatches translationMatch : myMatches) { ParametersParameterComponent matchParam = retVal.addParameter().setName("match"); translationMatch.toParameterParts(matchParam); } return retVal; }
Example #6
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public ValueSet expandValueset(ValueSet source, ExpansionProfile profile) { List<Header> headers = null; Parameters p = new Parameters(); p.addParameter().setName("valueSet").setResource(source); if (profile != null) p.addParameter().setName("profile").setResource(profile); ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"), utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405); result.addErrorStatus(422);//Unprocessable Entity result.addSuccessStatus(200); result.addSuccessStatus(201); if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } return (ValueSet) result.getPayload(); }
Example #7
Source File: BaseWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private ValidationResult verifyCodeExternal(ValueSet vs, Coding coding, boolean tryCache) throws Exception { ValidationResult res = vs == null ? null : handleByCache(vs, coding, tryCache); if (res != null) { return res; } Parameters pin = new Parameters(); pin.addParameter().setName("coding").setValue(coding); if (vs != null) { pin.addParameter().setName("valueSet").setResource(vs); } res = serverValidateCode(pin, vs == null); if (vs != null) { Map<String, ValidationResult> cache = validationCache.get(vs.getUrl()); cache.put(cacheId(coding), res); } return res; }
Example #8
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public ConceptMap updateClosure(String name, Coding coding) { Parameters params = new Parameters(); params.addParameter().setName("name").setValue(new StringType(name)); params.addParameter().setName("concept").setValue(coding); List<Header> headers = null; ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()), utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405); result.addErrorStatus(422);//Unprocessable Entity result.addSuccessStatus(200); result.addSuccessStatus(201); if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } return (ConceptMap) result.getPayload(); }
Example #9
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public ConceptMap initializeClosure(String name) { Parameters params = new Parameters(); params.addParameter().setName("name").setValue(new StringType(name)); List<Header> headers = null; ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()), utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405); result.addErrorStatus(422);//Unprocessable Entity result.addSuccessStatus(200); result.addSuccessStatus(201); if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } return (ConceptMap) result.getPayload(); }
Example #10
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public ValueSet expandValueset(ValueSet source, ExpansionProfile profile, Map<String, String> params) { List<Header> headers = null; Parameters p = new Parameters(); p.addParameter().setName("valueSet").setResource(source); if (profile != null) p.addParameter().setName("profile").setResource(profile); for (String n : params.keySet()) p.addParameter().setName(n).setValue(new StringType(params.get(n))); ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405); result.addErrorStatus(422);//Unprocessable Entity result.addSuccessStatus(200); result.addSuccessStatus(201); if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } return (ValueSet) result.getPayload(); }
Example #11
Source File: BaseWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private ValidationResult verifyCodeExternal(ValueSet vs, CodeableConcept cc, boolean tryCache) throws Exception { ValidationResult res = handleByCache(vs, cc, tryCache); if (res != null) { return res; } Parameters pin = new Parameters(); pin.addParameter().setName("codeableConcept").setValue(cc); pin.addParameter().setName("valueSet").setResource(vs); res = serverValidateCode(pin, false); Map<String, ValidationResult> cache = validationCache.get(vs.getUrl()); cache.put(cacheId(cc), res); return res; }
Example #12
Source File: BaseWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private String generateCacheName(Parameters pin) throws IOException { if (cache == null) { return null; } String json = new JsonParser().composeString(pin); return Utilities.path(cache, "vc" + Integer.toString(json.hashCode()) + ".json"); }
Example #13
Source File: LibraryOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
@Operation(name = "$get-narrative", idempotent = true, type = Library.class) public Parameters getNarrative(@IdParam IdType theId) { Library theResource = this.libraryResourceProvider.getDao().read(theId); Narrative n = this.narrativeProvider.getNarrative(this.libraryResourceProvider.getContext(), theResource); Parameters p = new Parameters(); p.addParameter().setValue(new StringType(n.getDivAsString())); return p; }
Example #14
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
@Operation(name = "$get-narrative", idempotent = true, type = Measure.class) public Parameters getNarrative(@IdParam IdType theId) { Measure theResource = this.measureResourceProvider.getDao().read(theId); CqfMeasure cqfMeasure = this.dataRequirementsProvider.createCqfMeasure(theResource, this.libraryResolutionProvider); Narrative n = this.narrativeProvider.getNarrative(this.measureResourceProvider.getContext(), cqfMeasure); Parameters p = new Parameters(); p.addParameter().setValue(new StringType(n.getDivAsString())); return p; }
Example #15
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
@Operation(name = "$collect-data", idempotent = true, type = Measure.class) public Parameters collectData(@IdParam IdType theId, @RequiredParam(name = "periodStart") String periodStart, @RequiredParam(name = "periodEnd") String periodEnd, @OptionalParam(name = "patient") String patientRef, @OptionalParam(name = "practitioner") String practitionerRef, @OptionalParam(name = "lastReceivedOn") String lastReceivedOn) throws FHIRException { // TODO: Spec says that the periods are not required, but I am not sure what to // do when they aren't supplied so I made them required MeasureReport report = evaluateMeasure(theId, periodStart, periodEnd, null, null, patientRef, null, practitionerRef, lastReceivedOn, null, null, null); report.setGroup(null); Parameters parameters = new Parameters(); parameters.addParameter( new Parameters.ParametersParameterComponent().setName("measurereport").setResource(report)); if (report.hasContained()) { for (Resource contained : report.getContained()) { if (contained instanceof Bundle) { addEvaluatedResourcesToParameters((Bundle) contained, parameters); } } } // TODO: need a way to resolve referenced resources within the evaluated // resources // Should be able to use _include search with * wildcard, but HAPI doesn't // support that return parameters; }
Example #16
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public Parameters lookupCode(Map<String, String> params) { ResourceRequest<Resource> result = utils.issueGetResourceRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup", params), getPreferredResourceFormat()); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405); result.addErrorStatus(422);//Unprocessable Entity result.addSuccessStatus(200); result.addSuccessStatus(201); if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } return (Parameters) result.getPayload(); }
Example #17
Source File: BaseWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
private ValidationResult serverValidateCode(Parameters pin, boolean doCache) throws Exception { if (noTerminologyServer) { return new ValidationResult(null, null, TerminologyServiceErrorClass.NOSERVICE); } String cacheName = doCache ? generateCacheName(pin) : null; ValidationResult res = loadFromCache(cacheName); if (res != null) { return res; } tlog("Terminology Server: $validate-code " + describeValidationParameters(pin)); for (ParametersParameterComponent pp : pin.getParameter()) { if (pp.getName().equals("profile")) { throw new Error("Can only specify profile in the context"); } } if (expProfile == null) { throw new Exception("No ExpansionProfile provided"); } pin.addParameter().setName("profile").setResource(expProfile); Parameters pout = txServer.operateType(ValueSet.class, "validate-code", pin); boolean ok = false; String message = "No Message returned"; String display = null; TerminologyServiceErrorClass err = TerminologyServiceErrorClass.UNKNOWN; for (ParametersParameterComponent p : pout.getParameter()) { if (p.getName().equals("result")) { ok = ((BooleanType) p.getValue()).getValue().booleanValue(); } else if (p.getName().equals("message")) { message = ((StringType) p.getValue()).getValue(); } else if (p.getName().equals("display")) { display = ((StringType) p.getValue()).getValue(); } else if (p.getName().equals("cause")) { try { IssueType it = IssueType.fromCode(((StringType) p.getValue()).getValue()); if (it == IssueType.UNKNOWN) { err = TerminologyServiceErrorClass.UNKNOWN; } else if (it == IssueType.NOTSUPPORTED) { err = TerminologyServiceErrorClass.VALUESET_UNSUPPORTED; } } catch (FHIRException e) { } } } if (!ok) { res = new ValidationResult(IssueSeverity.ERROR, message, err); } else if (display != null) { res = new ValidationResult(new ConceptDefinitionComponent().setDisplay(display)); } else { res = new ValidationResult(new ConceptDefinitionComponent()); } saveToCache(res, cacheName); return res; }
Example #18
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public Parameters getTerminologyCapabilities() { return (Parameters) utils.issueGetResourceRequest(resourceAddress.resolveMetadataTxCaps(), getPreferredResourceFormat()).getReference(); }