Search in sources :

Example 6 with Create

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

the class FamilyMemberHistoryResourceProvider method createFamilyMemberHistory.

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

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

the class ClaimResourceProvider method createClaim.

@Create
public MethodOutcome createClaim(@ResourceParam Claim claim) {
    MethodOutcome outcome = new MethodOutcome();
    Optional<List<IBilled>> created = getTransformer().createLocalObject(claim);
    if (created.isPresent() && !created.get().isEmpty()) {
        outcome.setCreated(true);
    } else {
        throw new InternalErrorException("Creation failed");
    }
    return outcome;
}
Also used : List(java.util.List) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) 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