use of ch.elexis.core.findings.IProcedureRequest in project elexis-server by elexis.
the class ServiceRequestResourceProvider method createProcedureRequest.
@Create
public MethodOutcome createProcedureRequest(@ResourceParam ServiceRequest procedureRequest) {
MethodOutcome outcome = new MethodOutcome();
Optional<IProcedureRequest> exists = getTransformer().getLocalObject(procedureRequest);
if (exists.isPresent()) {
outcome.setCreated(false);
outcome.setId(new IdType(procedureRequest.getId()));
} else {
Optional<IProcedureRequest> created = getTransformer().createLocalObject(procedureRequest);
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.IProcedureRequest in project elexis-server by elexis.
the class ServiceRequestResourceProvider method findProcedureRequest.
@Search()
public List<ServiceRequest> findProcedureRequest(@RequiredParam(name = ServiceRequest.SP_PATIENT) IdType thePatientId, @OptionalParam(name = ServiceRequest.SP_ENCOUNTER) IdType theEncounterId) {
if (thePatientId != null && !thePatientId.isEmpty()) {
Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
if (patient.isPresent()) {
if (patient.get().isPatient()) {
List<IProcedureRequest> findings = findingsService.getPatientsFindings(thePatientId.getIdPart(), IProcedureRequest.class);
if (theEncounterId != null) {
Optional<IEncounter> encounter = findingsService.findById(theEncounterId.getIdPart(), IEncounter.class);
if (encounter.isPresent()) {
IEncounter iEncounter = encounter.get();
String consid = iEncounter.getConsultationId();
if (consid != null && !consid.isEmpty()) {
findings = findingsService.getConsultationsFindings(consid, IProcedureRequest.class);
}
}
}
if (findings != null && !findings.isEmpty()) {
List<ServiceRequest> ret = new ArrayList<ServiceRequest>();
for (IProcedureRequest iFinding : findings) {
Optional<ServiceRequest> fhirProcedureRequest = getTransformer().getFhirObject(iFinding);
fhirProcedureRequest.ifPresent(pr -> ret.add(pr));
}
return ret;
}
}
}
}
return Collections.emptyList();
}
Aggregations