Search in sources :

Example 41 with IdType

use of org.hl7.fhir.dstu2.model.IdType 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 42 with IdType

use of org.hl7.fhir.dstu2.model.IdType 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 43 with IdType

use of org.hl7.fhir.dstu2.model.IdType in project elexis-server by elexis.

the class AllergyIntoleranceResourceProvider method findAllergyIntolerance.

@Search()
public List<AllergyIntolerance> findAllergyIntolerance(@RequiredParam(name = AllergyIntolerance.SP_PATIENT) IdType patientId) {
    if (patientId != null && !patientId.isEmpty()) {
        Optional<IPatient> patient = modelService.load(patientId.getIdPart(), IPatient.class);
        if (patient.isPresent()) {
            if (patient.get().isPatient()) {
                List<AllergyIntolerance> ret = new ArrayList<>();
                List<IAllergyIntolerance> findings = findingsService.getPatientsFindings(patientId.getIdPart(), IAllergyIntolerance.class);
                if (findings != null && !findings.isEmpty()) {
                    for (IAllergyIntolerance iFinding : findings) {
                        Optional<AllergyIntolerance> fhirAllergyIntolerance = getTransformer().getFhirObject(iFinding);
                        if (fhirAllergyIntolerance.isPresent()) {
                            ret.add(fhirAllergyIntolerance.get());
                        }
                    }
                }
                return ret;
            }
        }
    }
    return Collections.emptyList();
}
Also used : IAllergyIntolerance(ch.elexis.core.findings.IAllergyIntolerance) IAllergyIntolerance(ch.elexis.core.findings.IAllergyIntolerance) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) ArrayList(java.util.ArrayList) IPatient(ch.elexis.core.model.IPatient) Search(ca.uhn.fhir.rest.annotation.Search)

Example 44 with IdType

use of org.hl7.fhir.dstu2.model.IdType 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)

Example 45 with IdType

use of org.hl7.fhir.dstu2.model.IdType in project elexis-server by elexis.

the class CoverageResourceProvider method findCoverageByBeneficiary.

@Search()
public List<Coverage> findCoverageByBeneficiary(@RequiredParam(name = Coverage.SP_BENEFICIARY) IdType theBeneficiaryId) {
    if (theBeneficiaryId != null) {
        Optional<IPatient> patient = coreModelService.load(theBeneficiaryId.getIdPart(), IPatient.class);
        if (patient.isPresent()) {
            List<ICoverage> faelle = patient.get().getCoverages();
            if (faelle != null) {
                List<Coverage> ret = new ArrayList<Coverage>();
                for (ICoverage fall : faelle) {
                    Optional<Coverage> fhirCoverage = getTransformer().getFhirObject(fall);
                    fhirCoverage.ifPresent(fp -> ret.add(fp));
                }
                return ret;
            }
        }
    }
    return Collections.emptyList();
}
Also used : ICoverage(ch.elexis.core.model.ICoverage) ArrayList(java.util.ArrayList) ICoverage(ch.elexis.core.model.ICoverage) Coverage(org.hl7.fhir.r4.model.Coverage) IPatient(ch.elexis.core.model.IPatient) Search(ca.uhn.fhir.rest.annotation.Search)

Aggregations

IdType (org.hl7.fhir.r4.model.IdType)240 Test (org.junit.Test)240 IdType (org.hl7.fhir.dstu3.model.IdType)217 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)87 Test (org.junit.jupiter.api.Test)72 HashMap (java.util.HashMap)70 JsonObject (javax.json.JsonObject)55 Path (javax.ws.rs.Path)55 Produces (javax.ws.rs.Produces)55 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)50 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)49 Bundle (org.hl7.fhir.r4.model.Bundle)45 Date (java.util.Date)44 GET (javax.ws.rs.GET)40 ArrayList (java.util.ArrayList)38 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)36 Coding (org.hl7.fhir.r4.model.Coding)34 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)33 Resource (org.hl7.fhir.r4.model.Resource)33 Provenance (org.hl7.fhir.r4.model.Provenance)32