Search in sources :

Example 1 with ConditionClinicalStatusCodes

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

the class ConditionBundleFactory method createCondition.

protected Condition createCondition() {
    Condition healthConcern = new Condition();
    healthConcern.getMeta().addProfile(SDOHProfiles.CONDITION);
    ConditionClinicalStatusCodes clinicalStatus = ConditionClinicalStatusCodes.ACTIVE;
    healthConcern.setClinicalStatus(new CodeableConcept().addCoding(new Coding().setCode(clinicalStatus.toCode()).setSystem(clinicalStatus.getSystem()).setDisplay(clinicalStatus.getDisplay())));
    ConditionVerificationStatusCodes verificationStatus = ConditionVerificationStatusCodes.UNCONFIRMED;
    healthConcern.setVerificationStatus(new CodeableConcept().addCoding(new Coding().setCode(verificationStatus.toCode()).setSystem(verificationStatus.getSystem()).setDisplay(verificationStatus.getDisplay())));
    healthConcern.addCategory().addCoding(category);
    healthConcern.addCategory().addCoding(new Coding().setSystem(conditionType.getSystem()).setCode(conditionType.toCode()).setDisplay(conditionType.getDisplay()));
    healthConcern.getCode().setText(name);
    healthConcern.getCode().addCoding(icdCode);
    healthConcern.getCode().addCoding(snomedCode);
    healthConcern.setSubject(getPatientReference());
    healthConcern.setAsserter(getPatientReference());
    healthConcern.setRecorder(FhirUtil.toReference(Patient.class, practitioner.getIdElement().getIdPart(), practitioner.getNameFirstRep().getNameAsSingleString()));
    healthConcern.getEvidenceFirstRep().getCodeFirstRep().setText(basedOnText);
    return healthConcern;
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) ConditionVerificationStatusCodes(org.hl7.gravity.refimpl.sdohexchange.fhir.ConditionVerificationStatusCodes) ConditionClinicalStatusCodes(org.hl7.gravity.refimpl.sdohexchange.fhir.ConditionClinicalStatusCodes) Coding(org.hl7.fhir.r4.model.Coding) Patient(org.hl7.fhir.r4.model.Patient) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 2 with ConditionClinicalStatusCodes

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

the class HealthConcernService method remove.

public void remove(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)));
    ConditionClinicalStatusCodes resolvedStatus = ConditionClinicalStatusCodes.INACTIVE;
    Coding coding = healthConcern.getClinicalStatus().getCodingFirstRep();
    coding.setCode(resolvedStatus.toCode());
    coding.setDisplay(resolvedStatus.getDisplay());
    ehrClient.update().resource(healthConcern).execute();
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) ConditionClinicalStatusCodes(org.hl7.gravity.refimpl.sdohexchange.fhir.ConditionClinicalStatusCodes) 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) IdType(org.hl7.fhir.r4.model.IdType)

Example 3 with ConditionClinicalStatusCodes

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

the class ProblemService method close.

// TODO forbid close for problems WITH active tasks!
public void close(String id) {
    Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
    Bundle responseBundle = searchProblemQuery(ConditionClinicalStatusCodes.ACTIVE).where(Condition.RES_ID.exactly().code(id)).returnBundle(Bundle.class).execute();
    Condition problem = Optional.ofNullable(FhirUtil.getFirstFromBundle(responseBundle, Condition.class)).orElseThrow(() -> new ResourceNotFoundException(new IdType(Condition.class.getSimpleName(), id)));
    ConditionClinicalStatusCodes resolvedStatus = ConditionClinicalStatusCodes.RESOLVED;
    Coding coding = problem.getClinicalStatus().getCodingFirstRep();
    coding.setCode(resolvedStatus.toCode());
    coding.setDisplay(resolvedStatus.getDisplay());
    // set time of resolution
    problem.setAbatement(DateTimeType.now());
    ehrClient.update().resource(problem).execute();
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) ConditionClinicalStatusCodes(org.hl7.gravity.refimpl.sdohexchange.fhir.ConditionClinicalStatusCodes) 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) IdType(org.hl7.fhir.r4.model.IdType)

Example 4 with ConditionClinicalStatusCodes

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

the class HealthConcernService method resolve.

public void resolve(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)));
    ConditionClinicalStatusCodes resolvedStatus = ConditionClinicalStatusCodes.RESOLVED;
    Coding coding = healthConcern.getClinicalStatus().getCodingFirstRep();
    coding.setCode(resolvedStatus.toCode());
    coding.setDisplay(resolvedStatus.getDisplay());
    // set time of resolution
    healthConcern.setAbatement(DateTimeType.now());
    ehrClient.update().resource(healthConcern).execute();
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) ConditionClinicalStatusCodes(org.hl7.gravity.refimpl.sdohexchange.fhir.ConditionClinicalStatusCodes) 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) IdType(org.hl7.fhir.r4.model.IdType)

Aggregations

Coding (org.hl7.fhir.r4.model.Coding)4 Condition (org.hl7.fhir.r4.model.Condition)4 ConditionClinicalStatusCodes (org.hl7.gravity.refimpl.sdohexchange.fhir.ConditionClinicalStatusCodes)4 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)3 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)3 Bundle (org.hl7.fhir.r4.model.Bundle)3 IdType (org.hl7.fhir.r4.model.IdType)3 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Patient (org.hl7.fhir.r4.model.Patient)1 ConditionVerificationStatusCodes (org.hl7.gravity.refimpl.sdohexchange.fhir.ConditionVerificationStatusCodes)1