use of ch.elexis.core.findings.ICondition in project elexis-server by elexis.
the class ConditionResourceProvider method createCondition.
@Create
public MethodOutcome createCondition(@ResourceParam Condition condition) {
MethodOutcome outcome = new MethodOutcome();
Optional<ICondition> exists = getTransformer().getLocalObject(condition);
if (exists.isPresent()) {
outcome.setCreated(false);
outcome.setId(new IdType(condition.getId()));
} else {
Optional<ICondition> created = getTransformer().createLocalObject(condition);
if (created.isPresent()) {
outcome.setCreated(true);
outcome.setId(new IdType(created.get().getId()));
} else {
throw new InternalErrorException("Creation failed");
}
}
return outcome;
}
use of ch.elexis.core.findings.ICondition in project elexis-server by elexis.
the class MigratorService method migratePatientCondition.
/**
* Migrate the existing diagnose text of a patient to an {@link ICondition} instance. Migration
* is only performed if there is not already a diagnose in form of an {@link ICondition} present
* for the patient.
*
* @param patientId
*/
private void migratePatientCondition(String patientId) {
Optional<IPatient> patient = CoreModelServiceHolder.get().load(patientId, IPatient.class);
patient.ifPresent(p -> {
String diagnosis = p.getDiagnosen();
if (diagnosis != null && !diagnosis.isEmpty()) {
List<ICondition> conditions = findingsService.getPatientsFindings(patientId, ICondition.class);
conditions = conditions.stream().filter(iFinding -> isDiagnose(iFinding)).collect(Collectors.toList());
if (conditions.isEmpty()) {
ICondition condition = findingsService.create(ICondition.class);
condition.setPatientId(patientId);
condition.setCategory(ConditionCategory.PROBLEMLISTITEM);
condition.setText(diagnosis);
findingsService.saveFinding(condition);
}
}
});
}
use of ch.elexis.core.findings.ICondition in project elexis-server by elexis.
the class ConditionResourceProvider method findCondition.
@Search()
public List<Condition> findCondition(@RequiredParam(name = Condition.SP_SUBJECT) IdType thePatientId, @OptionalParam(name = Condition.SP_CATEGORY) CodeType categoryCode) {
if (thePatientId != null && !thePatientId.isEmpty()) {
Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
if (patient.isPresent()) {
if (patient.get().isPatient()) {
// migrate diagnose condition first
migratorService.migratePatientsFindings(thePatientId.getIdPart(), ICondition.class, null);
List<ICondition> findings = findingsService.getPatientsFindings(thePatientId.getIdPart(), ICondition.class);
if (findings != null && !findings.isEmpty()) {
List<Condition> ret = new ArrayList<Condition>();
for (ICondition iFinding : findings) {
if (categoryCode != null && !isConditionCategory(iFinding, categoryCode)) {
continue;
}
Optional<Condition> fhirEncounter = getTransformer().getFhirObject(iFinding);
fhirEncounter.ifPresent(fe -> ret.add(fe));
}
return ret;
}
}
}
}
return Collections.emptyList();
}
Aggregations