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;
}
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();
}
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();
}
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();
}
Aggregations