Search in sources :

Example 1 with UsCoreConditionCategory

use of org.hl7.gravity.refimpl.sdohexchange.fhir.UsCoreConditionCategory in project Gravity-SDOH-Exchange-RI by FHIR.

the class ConditionBundleFactory method createBundle.

public Bundle createBundle() {
    Assert.notNull(name, "Name cannot be null.");
    Assert.notNull(category, "SDOH DomainCode cannot be null.");
    Assert.notNull(conditionType, "UsCoreConditionCategory cannot be null.");
    Assert.notNull(icdCode, "ICD-10 code cannot be null.");
    Assert.notNull(snomedCode, "SNOMED-CT code cannot be null.");
    Assert.notNull(patient, "Patient cannot be null.");
    Assert.notNull(practitioner, "Practitioner cannot be null.");
    Assert.hasText(basedOnText, "BaseOn text cannot be null or empty.");
    Bundle bundle = new Bundle();
    bundle.setType(Bundle.BundleType.TRANSACTION);
    Condition healthConcern = createCondition();
    bundle.addEntry(FhirUtil.createPostEntry(healthConcern));
    return bundle;
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Bundle(org.hl7.fhir.r4.model.Bundle)

Example 2 with UsCoreConditionCategory

use of org.hl7.gravity.refimpl.sdohexchange.fhir.UsCoreConditionCategory in project Gravity-SDOH-Exchange-RI by FHIR.

the class HealthConcernService method promote.

public void promote(String id) {
    Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
    Bundle responseBundle = searchHealthConcernQuery(ConditionClinicalStatus.ACTIVE).where(Condition.RES_ID.exactly().code(id)).returnBundle(Bundle.class).execute();
    Condition healthConcern = Optional.ofNullable(FhirUtil.getFirstFromBundle(responseBundle, Condition.class)).orElseThrow(() -> new ResourceNotFoundException(new IdType(Condition.class.getSimpleName(), id)));
    UsCoreConditionCategory problem = UsCoreConditionCategory.PROBLEMLISTITEM;
    Coding coding = FhirUtil.findCoding(healthConcern.getCategory(), problem.getSystem());
    coding.setCode(problem.toCode());
    coding.setDisplay(problem.getDisplay());
    // set time when the problem becomes effective
    healthConcern.setOnset(DateTimeType.now());
    ehrClient.update().resource(healthConcern).execute();
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Coding(org.hl7.fhir.r4.model.Coding) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) UsCoreConditionCategory(org.hl7.gravity.refimpl.sdohexchange.fhir.UsCoreConditionCategory) IdType(org.hl7.fhir.r4.model.IdType)

Aggregations

Bundle (org.hl7.fhir.r4.model.Bundle)2 Condition (org.hl7.fhir.r4.model.Condition)2 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)1 Coding (org.hl7.fhir.r4.model.Coding)1 IdType (org.hl7.fhir.r4.model.IdType)1 UsCoreConditionCategory (org.hl7.gravity.refimpl.sdohexchange.fhir.UsCoreConditionCategory)1