use of ch.elexis.core.model.IPrescription in project elexis-server by elexis.
the class MedicationRequestResourceProvider method findMedicationsByPatient.
@Search()
public List<MedicationRequest> findMedicationsByPatient(@RequiredParam(name = MedicationRequest.SP_PATIENT) IdType thePatientId) {
if (thePatientId != null && !thePatientId.isEmpty()) {
Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
if (patient.isPresent()) {
if (patient.get().isPatient()) {
IQuery<IPrescription> query = modelService.getQuery(IPrescription.class);
query.and(ModelPackage.Literals.IPRESCRIPTION__PATIENT, COMPARATOR.EQUALS, patient.get());
// TODO
// qbe.add(Prescription_.rezeptID, JPAQuery.QUERY.EQUALS, null);
List<IPrescription> prescriptions = query.execute();
if (prescriptions != null && !prescriptions.isEmpty()) {
List<MedicationRequest> ret = new ArrayList<MedicationRequest>();
for (IPrescription prescription : prescriptions) {
Optional<MedicationRequest> fhirMedicationOrder = getTransformer().getFhirObject(prescription);
fhirMedicationOrder.ifPresent(fmo -> ret.add(fmo));
}
return ret;
}
}
}
}
return null;
}
use of ch.elexis.core.model.IPrescription in project elexis-server by elexis.
the class MedicationRequestResourceProvider method updateMedicationOrder.
@Update
public MethodOutcome updateMedicationOrder(@ResourceParam MedicationRequest updateOrder) {
Optional<IPrescription> localObject = getTransformer().getLocalObject(updateOrder);
MethodOutcome outcome = new MethodOutcome();
outcome.setCreated(false);
if (localObject.isPresent()) {
try {
Optional<IPrescription> updated = getTransformer().updateLocalObject(updateOrder, localObject.get());
updated.ifPresent(prescription -> {
outcome.setCreated(true);
outcome.setId(new IdType(prescription.getId()));
});
} catch (RuntimeException e) {
OperationOutcome issueOutcome = new OperationOutcome();
issueOutcome.addIssue().setDiagnostics("Update failed. " + e.getMessage());
outcome.setOperationOutcome(issueOutcome);
}
} else {
OperationOutcome issueOutcome = new OperationOutcome();
issueOutcome.addIssue().setDiagnostics("No local object found");
outcome.setOperationOutcome(issueOutcome);
}
return outcome;
}
Aggregations