ca.uhn.fhir.rest.server.exceptions.InternalErrorException Java Examples
The following examples show how to use
ca.uhn.fhir.rest.server.exceptions.InternalErrorException.
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: FHIRPathEngine.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private List<Base> opLessThen(List<Base> left, List<Base> right) throws FHIRException { if (left.size() == 1 && right.size() == 1 && left.get(0).isPrimitive() && right.get(0).isPrimitive()) { Base l = left.get(0); Base r = right.get(0); if (l.hasType("string") && r.hasType("string")) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) < 0); else if ((l.hasType("integer") || l.hasType("decimal")) && (r.hasType("integer") || r.hasType("decimal"))) return makeBoolean(new Double(l.primitiveValue()) < new Double(r.primitiveValue())); else if ((l.hasType("date", "dateTime", "instant")) && (r.hasType("date", "dateTime", "instant"))) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) < 0); else if ((l.hasType("time")) && (r.hasType("time"))) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) < 0); } else if (left.size() == 1 && right.size() == 1 && left.get(0).fhirType().equals("Quantity") && right.get(0).fhirType().equals("Quantity") ) { List<Base> lUnit = left.get(0).listChildrenByName("unit"); List<Base> rUnit = right.get(0).listChildrenByName("unit"); if (Base.compareDeep(lUnit, rUnit, true)) { return opLessThen(left.get(0).listChildrenByName("value"), right.get(0).listChildrenByName("value")); } else { throw new InternalErrorException("Canonical Comparison isn't done yet"); } } return new ArrayList<Base>(); }
Example #2
Source File: FHIRPathEngine.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private List<Base> opGreater(List<Base> left, List<Base> right) throws FHIRException { if (left.size() == 1 && right.size() == 1 && left.get(0).isPrimitive() && right.get(0).isPrimitive()) { Base l = left.get(0); Base r = right.get(0); if (l.hasType("string") && r.hasType("string")) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) > 0); else if ((l.hasType("integer", "decimal", "unsignedInt", "positiveInt")) && (r.hasType("integer", "decimal", "unsignedInt", "positiveInt"))) return makeBoolean(new Double(l.primitiveValue()) > new Double(r.primitiveValue())); else if ((l.hasType("date", "dateTime", "instant")) && (r.hasType("date", "dateTime", "instant"))) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) > 0); else if ((l.hasType("time")) && (r.hasType("time"))) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) > 0); } else if (left.size() == 1 && right.size() == 1 && left.get(0).fhirType().equals("Quantity") && right.get(0).fhirType().equals("Quantity") ) { List<Base> lUnit = left.get(0).listChildrenByName("unit"); List<Base> rUnit = right.get(0).listChildrenByName("unit"); if (Base.compareDeep(lUnit, rUnit, true)) { return opGreater(left.get(0).listChildrenByName("value"), right.get(0).listChildrenByName("value")); } else { throw new InternalErrorException("Canonical Comparison isn't done yet"); } } return new ArrayList<Base>(); }
Example #3
Source File: FHIRPathEngine.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private List<Base> opLessOrEqual(List<Base> left, List<Base> right) throws FHIRException { if (left.size() == 1 && right.size() == 1 && left.get(0).isPrimitive() && right.get(0).isPrimitive()) { Base l = left.get(0); Base r = right.get(0); if (l.hasType("string") && r.hasType("string")) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) <= 0); else if ((l.hasType("integer", "decimal", "unsignedInt", "positiveInt")) && (r.hasType("integer", "decimal", "unsignedInt", "positiveInt"))) return makeBoolean(new Double(l.primitiveValue()) <= new Double(r.primitiveValue())); else if ((l.hasType("date", "dateTime", "instant")) && (r.hasType("date", "dateTime", "instant"))) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) <= 0); else if ((l.hasType("time")) && (r.hasType("time"))) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) <= 0); } else if (left.size() == 1 && right.size() == 1 && left.get(0).fhirType().equals("Quantity") && right.get(0).fhirType().equals("Quantity") ) { List<Base> lUnits = left.get(0).listChildrenByName("unit"); String lunit = lUnits.size() == 1 ? lUnits.get(0).primitiveValue() : null; List<Base> rUnits = right.get(0).listChildrenByName("unit"); String runit = rUnits.size() == 1 ? rUnits.get(0).primitiveValue() : null; if ((lunit == null && runit == null) || lunit.equals(runit)) { return opLessOrEqual(left.get(0).listChildrenByName("value"), right.get(0).listChildrenByName("value")); } else { throw new InternalErrorException("Canonical Comparison isn't done yet"); } } return new ArrayList<Base>(); }
Example #4
Source File: FHIRPathEngine.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private List<Base> opGreaterOrEqual(List<Base> left, List<Base> right) throws FHIRException { if (left.size() == 1 && right.size() == 1 && left.get(0).isPrimitive() && right.get(0).isPrimitive()) { Base l = left.get(0); Base r = right.get(0); if (l.hasType("string") && r.hasType("string")) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) >= 0); else if ((l.hasType("integer", "decimal", "unsignedInt", "positiveInt")) && (r.hasType("integer", "decimal", "unsignedInt", "positiveInt"))) return makeBoolean(new Double(l.primitiveValue()) >= new Double(r.primitiveValue())); else if ((l.hasType("date", "dateTime", "instant")) && (r.hasType("date", "dateTime", "instant"))) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) >= 0); else if ((l.hasType("time")) && (r.hasType("time"))) return makeBoolean(l.primitiveValue().compareTo(r.primitiveValue()) >= 0); } else if (left.size() == 1 && right.size() == 1 && left.get(0).fhirType().equals("Quantity") && right.get(0).fhirType().equals("Quantity") ) { List<Base> lUnit = left.get(0).listChildrenByName("unit"); List<Base> rUnit = right.get(0).listChildrenByName("unit"); if (Base.compareDeep(lUnit, rUnit, true)) { return opGreaterOrEqual(left.get(0).listChildrenByName("value"), right.get(0).listChildrenByName("value")); } else { throw new InternalErrorException("Canonical Comparison isn't done yet"); } } return new ArrayList<Base>(); }
Example #5
Source File: ActivityDefinitionApplyProvider.java From cqf-ruler with Apache License 2.0 | 6 votes |
@Operation(name = "$apply", idempotent = true, type = ActivityDefinition.class) public Resource apply(@IdParam IdType theId, @RequiredParam(name="patient") String patientId, @OptionalParam(name="encounter") String encounterId, @OptionalParam(name="practitioner") String practitionerId, @OptionalParam(name="organization") String organizationId, @OptionalParam(name="userType") String userType, @OptionalParam(name="userLanguage") String userLanguage, @OptionalParam(name="userTaskContext") String userTaskContext, @OptionalParam(name="setting") String setting, @OptionalParam(name="settingContext") String settingContext) throws InternalErrorException, FHIRException, ClassNotFoundException, IllegalAccessException, InstantiationException, ActivityDefinitionApplyException { ActivityDefinition activityDefinition; try { activityDefinition = this.activityDefinitionDao.read(theId); } catch (Exception e) { return Helper.createErrorOutcome("Unable to resolve ActivityDefinition/" + theId.getValueAsString()); } return resolveActivityDefinition(activityDefinition, patientId, practitionerId, organizationId); }
Example #6
Source File: ActivityDefinitionApplyProvider.java From cqf-ruler with Apache License 2.0 | 6 votes |
@Operation(name = "$apply", idempotent = true, type = ActivityDefinition.class) public Resource apply(@IdParam IdType theId, @RequiredParam(name = "patient") String patientId, @OptionalParam(name = "encounter") String encounterId, @OptionalParam(name = "practitioner") String practitionerId, @OptionalParam(name = "organization") String organizationId, @OptionalParam(name = "userType") String userType, @OptionalParam(name = "userLanguage") String userLanguage, @OptionalParam(name = "userTaskContext") String userTaskContext, @OptionalParam(name = "setting") String setting, @OptionalParam(name = "settingContext") String settingContext) throws InternalErrorException, FHIRException, ClassNotFoundException, IllegalAccessException, InstantiationException, ActivityDefinitionApplyException { ActivityDefinition activityDefinition; try { activityDefinition = this.activityDefinitionDao.read(theId); } catch (Exception e) { return Helper.createErrorOutcome("Unable to resolve ActivityDefinition/" + theId.getValueAsString()); } return resolveActivityDefinition(activityDefinition, patientId, practitionerId, organizationId); }
Example #7
Source File: ProviderResponseLibrary.java From careconnect-reference-implementation with Apache License 2.0 | 5 votes |
public static void createException(FhirContext ctx, IBaseResource resource) { if (resource instanceof OperationOutcome) { OperationOutcome operationOutcome = (OperationOutcome) resource; if (ctx != null) { String json = ctx.newJsonParser().encodeResourceToString(operationOutcome); log.info("Sever Returned: {}", json); } OperationOutcomeFactory.convertToException(operationOutcome); } else { throw new InternalErrorException("Server Error"); } }
Example #8
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
@Operation(name = "$data-requirements", idempotent = true, type = Measure.class) public org.hl7.fhir.dstu3.model.Library dataRequirements(@IdParam IdType theId, @RequiredParam(name = "startPeriod") String startPeriod, @RequiredParam(name = "endPeriod") String endPeriod) throws InternalErrorException, FHIRException { Measure measure = this.measureResourceProvider.getDao().read(theId); return this.dataRequirementsProvider.getDataRequirements(measure, this.libraryResolutionProvider); }
Example #9
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
@Operation(name = "$data-requirements", idempotent = true, type = Measure.class) public org.hl7.fhir.r4.model.Library dataRequirements(@IdParam IdType theId, @RequiredParam(name = "startPeriod") String startPeriod, @RequiredParam(name = "endPeriod") String endPeriod) throws InternalErrorException, FHIRException { Measure measure = this.measureResourceProvider.getDao().read(theId); return this.dataRequirementsProvider.getDataRequirements(measure, this.libraryResolutionProvider); }
Example #10
Source File: JarEnabledCustomThymeleafNarrativeGenerator.java From cqf-ruler with Apache License 2.0 | 5 votes |
private synchronized void initialize() { if (myInitialized) { return; } List<String> propFileName = getPropertyFile(); try { NarrativeTemplateManifest manifest = forManifestFileLocation(propFileName); setManifest(manifest); } catch (IOException e) { throw new InternalErrorException(e); } myInitialized = true; }
Example #11
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 4 votes |
@Operation(name = "$evaluate-measure", idempotent = true, type = Measure.class) public MeasureReport evaluateMeasure(@IdParam IdType theId, @RequiredParam(name = "periodStart") String periodStart, @RequiredParam(name = "periodEnd") String periodEnd, @OptionalParam(name = "measure") String measureRef, @OptionalParam(name = "reportType") String reportType, @OptionalParam(name = "patient") String patientRef, @OptionalParam(name = "productLine") String productLine, @OptionalParam(name = "practitioner") String practitionerRef, @OptionalParam(name = "lastReceivedOn") String lastReceivedOn, @OptionalParam(name = "source") String source, @OptionalParam(name = "user") String user, @OptionalParam(name = "pass") String pass) throws InternalErrorException, FHIRException { LibraryLoader libraryLoader = LibraryHelper.createLibraryLoader(this.libraryResolutionProvider); MeasureEvaluationSeed seed = new MeasureEvaluationSeed(this.factory, libraryLoader, this.libraryResolutionProvider); Measure measure = this.measureResourceProvider.getDao().read(theId); if (measure == null) { throw new RuntimeException("Could not find Measure/" + theId.getIdPart()); } seed.setup(measure, periodStart, periodEnd, productLine, source, user, pass); // resolve report type MeasureEvaluation evaluator = new MeasureEvaluation(seed.getDataProvider(), this.registry, seed.getMeasurementPeriod()); if (reportType != null) { switch (reportType) { case "patient": return evaluator.evaluatePatientMeasure(seed.getMeasure(), seed.getContext(), patientRef); case "patient-list": return evaluator.evaluatePatientListMeasure(seed.getMeasure(), seed.getContext(), practitionerRef); case "population": return evaluator.evaluatePopulationMeasure(seed.getMeasure(), seed.getContext()); default: throw new IllegalArgumentException("Invalid report type: " + reportType); } } // default report type is patient MeasureReport report = evaluator.evaluatePatientMeasure(seed.getMeasure(), seed.getContext(), patientRef); if (productLine != null) { Extension ext = new Extension(); ext.setUrl("http://hl7.org/fhir/us/cqframework/cqfmeasures/StructureDefinition/cqfm-productLine"); ext.setValue(new StringType(productLine)); report.addExtension(ext); } return report; }
Example #12
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 4 votes |
@Operation(name = "$evaluate-measure", idempotent = true, type = Measure.class) public MeasureReport evaluateMeasure(@IdParam IdType theId, @RequiredParam(name = "periodStart") String periodStart, @RequiredParam(name = "periodEnd") String periodEnd, @OptionalParam(name = "measure") String measureRef, @OptionalParam(name = "reportType") String reportType, @OptionalParam(name = "patient") String patientRef, @OptionalParam(name = "productLine") String productLine, @OptionalParam(name = "practitioner") String practitionerRef, @OptionalParam(name = "lastReceivedOn") String lastReceivedOn, @OptionalParam(name = "source") String source, @OptionalParam(name = "user") String user, @OptionalParam(name = "pass") String pass) throws InternalErrorException, FHIRException { LibraryLoader libraryLoader = LibraryHelper.createLibraryLoader(this.libraryResolutionProvider); MeasureEvaluationSeed seed = new MeasureEvaluationSeed(this.factory, libraryLoader, this.libraryResolutionProvider); Measure measure = this.measureResourceProvider.getDao().read(theId); if (measure == null) { throw new RuntimeException("Could not find Measure/" + theId.getIdPart()); } seed.setup(measure, periodStart, periodEnd, productLine, source, user, pass); // resolve report type MeasureEvaluation evaluator = new MeasureEvaluation(seed.getDataProvider(), this.registry, seed.getMeasurementPeriod()); if (reportType != null) { switch (reportType) { case "patient": return evaluator.evaluatePatientMeasure(seed.getMeasure(), seed.getContext(), patientRef); case "patient-list": return evaluator.evaluateSubjectListMeasure(seed.getMeasure(), seed.getContext(), practitionerRef); case "population": return evaluator.evaluatePopulationMeasure(seed.getMeasure(), seed.getContext()); default: throw new IllegalArgumentException("Invalid report type: " + reportType); } } // default report type is patient MeasureReport report = evaluator.evaluatePatientMeasure(seed.getMeasure(), seed.getContext(), patientRef); if (productLine != null) { Extension ext = new Extension(); ext.setUrl("http://hl7.org/fhir/us/cqframework/cqfmeasures/StructureDefinition/cqfm-productLine"); ext.setValue(new StringType(productLine)); report.addExtension(ext); } return report; }