Search in sources :

Example 1 with Create

use of ca.uhn.fhir.rest.annotation.Create in project elexis-server by elexis.

the class ObservationResourceProvider method createObservation.

@Create
public MethodOutcome createObservation(@ResourceParam Observation observation) {
    MethodOutcome outcome = new MethodOutcome();
    Optional<IObservation> exists = getTransformer().getLocalObject(observation);
    if (exists.isPresent()) {
        outcome.setCreated(false);
        outcome.setId(new IdType(observation.getId()));
    } else {
        Optional<IObservation> created = getTransformer().createLocalObject(observation);
        if (created.isPresent()) {
            outcome.setCreated(true);
            outcome.setId(new IdType(created.get().getId()));
        } else {
            throw new InternalErrorException("Creation failed");
        }
    }
    return outcome;
}
Also used : InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IObservation(ch.elexis.core.findings.IObservation) IdType(org.hl7.fhir.r4.model.IdType) Create(ca.uhn.fhir.rest.annotation.Create)

Example 2 with Create

use of ca.uhn.fhir.rest.annotation.Create 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 3 with Create

use of ca.uhn.fhir.rest.annotation.Create in project elexis-server by elexis.

the class AbstractFhirCrudResourceProvider method create.

@Create
public MethodOutcome create(@ResourceParam FHIR fhirObject) {
    MethodOutcome outcome = new MethodOutcome();
    Optional<ELEXIS> exists = getTransformer().getLocalObject(fhirObject);
    if (exists.isPresent()) {
        outcome.setCreated(false);
        outcome.setId(new IdType(fhirObject.getId()));
    } else {
        outcome = resourceProviderUtil.createResource(getTransformer(), fhirObject, log);
    }
    return outcome;
}
Also used : MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.r4.model.IdType) Create(ca.uhn.fhir.rest.annotation.Create)

Example 4 with Create

use of ca.uhn.fhir.rest.annotation.Create in project elexis-server by elexis.

the class AllergyIntoleranceResourceProvider method createAllergyIntolerance.

@Create
public MethodOutcome createAllergyIntolerance(@ResourceParam AllergyIntolerance allergyIntolerance) {
    MethodOutcome outcome = new MethodOutcome();
    Optional<IAllergyIntolerance> exists = getTransformer().getLocalObject(allergyIntolerance);
    if (exists.isPresent()) {
        outcome.setCreated(false);
        outcome.setId(new IdType(allergyIntolerance.getId()));
    } else {
        Optional<IAllergyIntolerance> created = getTransformer().createLocalObject(allergyIntolerance);
        if (created.isPresent()) {
            outcome.setCreated(true);
            outcome.setId(new IdType(created.get().getId()));
        } else {
            throw new InternalErrorException("Creation failed");
        }
    }
    return outcome;
}
Also used : IAllergyIntolerance(ch.elexis.core.findings.IAllergyIntolerance) 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 5 with Create

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

Aggregations

Create (ca.uhn.fhir.rest.annotation.Create)7 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)7 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)6 IdType (org.hl7.fhir.r4.model.IdType)6 IAllergyIntolerance (ch.elexis.core.findings.IAllergyIntolerance)1 ICondition (ch.elexis.core.findings.ICondition)1 IFamilyMemberHistory (ch.elexis.core.findings.IFamilyMemberHistory)1 IObservation (ch.elexis.core.findings.IObservation)1 IProcedureRequest (ch.elexis.core.findings.IProcedureRequest)1 List (java.util.List)1