Search in sources :

Example 1 with IAllergyIntolerance

use of ch.elexis.core.findings.IAllergyIntolerance 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 2 with IAllergyIntolerance

use of ch.elexis.core.findings.IAllergyIntolerance 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 3 with IAllergyIntolerance

use of ch.elexis.core.findings.IAllergyIntolerance in project elexis-server by elexis.

the class AllergyIntoleranceTest method setupClass.

@BeforeClass
public static void setupClass() throws IOException, SQLException {
    AllTests.getTestDatabaseInitializer().initializePatient();
    client = FhirUtil.getGenericClient("http://localhost:8380/fhir");
    assertNotNull(client);
    IAllergyIntolerance allergyIntolerance = AllTests.getFindingsService().create(IAllergyIntolerance.class);
    allergyIntolerance.setText("Allergy Intolerance test 1");
    allergyIntolerance.setPatientId(AllTests.getTestDatabaseInitializer().getPatient().getId());
    AllTests.getFindingsService().saveFinding(allergyIntolerance);
}
Also used : IAllergyIntolerance(ch.elexis.core.findings.IAllergyIntolerance) BeforeClass(org.junit.BeforeClass)

Aggregations

IAllergyIntolerance (ch.elexis.core.findings.IAllergyIntolerance)3 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 IPatient (ch.elexis.core.model.IPatient)1 ArrayList (java.util.ArrayList)1 AllergyIntolerance (org.hl7.fhir.r4.model.AllergyIntolerance)1 IdType (org.hl7.fhir.r4.model.IdType)1 BeforeClass (org.junit.BeforeClass)1