Search in sources :

Example 1 with IProcedureRequest

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;
}
Also used : IProcedureRequest(ch.elexis.core.findings.IProcedureRequest) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.r4.model.IdType) Create(ca.uhn.fhir.rest.annotation.Create)

Example 2 with IProcedureRequest

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();
}
Also used : IProcedureRequest(ch.elexis.core.findings.IProcedureRequest) IEncounter(ch.elexis.core.findings.IEncounter) ArrayList(java.util.ArrayList) IPatient(ch.elexis.core.model.IPatient) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Search(ca.uhn.fhir.rest.annotation.Search)

Aggregations

IProcedureRequest (ch.elexis.core.findings.IProcedureRequest)2 Create (ca.uhn.fhir.rest.annotation.Create)1 Search (ca.uhn.fhir.rest.annotation.Search)1 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)1 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)1 IEncounter (ch.elexis.core.findings.IEncounter)1 IPatient (ch.elexis.core.model.IPatient)1 ArrayList (java.util.ArrayList)1 IdType (org.hl7.fhir.r4.model.IdType)1 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)1