Search in sources :

Example 1 with IPatient

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

use of ch.elexis.core.model.IPatient in project elexis-server by elexis.

the class MigratorService method updateEncounter.

private void updateEncounter(IEncounter findingsEncounter, ch.elexis.core.model.IEncounter encounter) {
    findingsEncounter.setConsultationId(encounter.getId());
    findingsEncounter.setMandatorId(encounter.getMandator().getId());
    LocalDate encounterDate = encounter.getDate();
    if (encounterDate != null) {
        findingsEncounter.setStartTime(encounterDate.atStartOfDay());
        findingsEncounter.setEndTime(encounterDate.atTime(23, 59, 59));
    }
    ICoverage coverage = encounter.getCoverage();
    if (coverage != null) {
        IPatient patient = coverage.getPatient();
        if (patient != null) {
            findingsEncounter.setPatientId(patient.getId());
        }
    }
    VersionedResource vr = encounter.getVersionedEntry();
    if (vr != null) {
        Samdas samdas = new Samdas(vr.getHead());
        findingsEncounter.setText(samdas.getRecordText());
    }
    List<ICoding> coding = findingsEncounter.getType();
    if (!ModelUtil.isSystemInList(CodingSystem.ELEXIS_ENCOUNTER_TYPE.getSystem(), coding)) {
        coding.add(new TransientCoding(CodingSystem.ELEXIS_ENCOUNTER_TYPE.getSystem(), "text", "Nicht strukturierte Konsultation"));
        findingsEncounter.setType(coding);
    }
    findingsService.saveFinding(findingsEncounter);
}
Also used : ICoding(ch.elexis.core.findings.ICoding) ICoverage(ch.elexis.core.model.ICoverage) TransientCoding(ch.elexis.core.findings.util.model.TransientCoding) Samdas(ch.elexis.core.text.model.Samdas) LocalDate(java.time.LocalDate) VersionedResource(ch.rgw.tools.VersionedResource) IPatient(ch.elexis.core.model.IPatient)

Example 3 with IPatient

use of ch.elexis.core.model.IPatient 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)

Example 4 with IPatient

use of ch.elexis.core.model.IPatient in project elexis-server by elexis.

the class MedicationRequestResourceProvider method findMedicationsByPatient.

@Search()
public List<MedicationRequest> findMedicationsByPatient(@RequiredParam(name = MedicationRequest.SP_PATIENT) IdType thePatientId) {
    if (thePatientId != null && !thePatientId.isEmpty()) {
        Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
        if (patient.isPresent()) {
            if (patient.get().isPatient()) {
                IQuery<IPrescription> query = modelService.getQuery(IPrescription.class);
                query.and(ModelPackage.Literals.IPRESCRIPTION__PATIENT, COMPARATOR.EQUALS, patient.get());
                // TODO
                // qbe.add(Prescription_.rezeptID, JPAQuery.QUERY.EQUALS, null);
                List<IPrescription> prescriptions = query.execute();
                if (prescriptions != null && !prescriptions.isEmpty()) {
                    List<MedicationRequest> ret = new ArrayList<MedicationRequest>();
                    for (IPrescription prescription : prescriptions) {
                        Optional<MedicationRequest> fhirMedicationOrder = getTransformer().getFhirObject(prescription);
                        fhirMedicationOrder.ifPresent(fmo -> ret.add(fmo));
                    }
                    return ret;
                }
            }
        }
    }
    return null;
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) IPrescription(ch.elexis.core.model.IPrescription) ArrayList(java.util.ArrayList) IPatient(ch.elexis.core.model.IPatient) Search(ca.uhn.fhir.rest.annotation.Search)

Example 5 with IPatient

use of ch.elexis.core.model.IPatient in project elexis-server by elexis.

the class PatientTest method createDeletePatient.

@Test
public void createDeletePatient() {
    Patient patient = new Patient();
    HumanName hn = new HumanName();
    hn.setUse(NameUse.OFFICIAL);
    hn.setFamily("familyName");
    patient.setName(Collections.singletonList(hn));
    patient.setBirthDate(new Date());
    Address address = new Address();
    address.setCity("City");
    address.setCountry("CH");
    patient.setAddress(Collections.singletonList(address));
    // create
    MethodOutcome execute = client.create().resource(patient).execute();
    assertTrue(execute.getCreated());
    assertNotNull(execute.getId());
    assertEquals("Patient", execute.getId().getResourceType());
    IIdType id = execute.getId();
    Patient created = client.read().resource(Patient.class).withId(id).execute();
    assertEquals(hn.getFamily(), created.getName().get(0).getFamily());
    // delete
    client.delete().resource(created).execute();
    Optional<IPatient> load = AllTests.getModelService().load(id.getIdPart(), IPatient.class, true);
    assertTrue(load.isPresent());
    assertTrue(load.get().isDeleted());
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Address(org.hl7.fhir.r4.model.Address) Patient(org.hl7.fhir.r4.model.Patient) IPatient(ch.elexis.core.model.IPatient) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Date(java.util.Date) LocalDate(java.time.LocalDate) IPatient(ch.elexis.core.model.IPatient) IIdType(org.hl7.fhir.instance.model.api.IIdType) Test(org.junit.Test)

Aggregations

IPatient (ch.elexis.core.model.IPatient)14 Search (ca.uhn.fhir.rest.annotation.Search)9 ArrayList (java.util.ArrayList)8 IEncounter (ch.elexis.core.findings.IEncounter)3 LocalDate (java.time.LocalDate)3 OptionalParam (ca.uhn.fhir.rest.annotation.OptionalParam)2 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)2 ICondition (ch.elexis.core.findings.ICondition)2 IFhirTransformer (ch.elexis.core.findings.util.fhir.IFhirTransformer)2 IFhirTransformerRegistry (ch.elexis.core.findings.util.fhir.IFhirTransformerRegistry)2 ICoverage (ch.elexis.core.model.ICoverage)2 ModelPackage (ch.elexis.core.model.ModelPackage)2 IModelService (ch.elexis.core.services.IModelService)2 IQuery (ch.elexis.core.services.IQuery)2 COMPARATOR (ch.elexis.core.services.IQuery.COMPARATOR)2 Collections (java.util.Collections)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)2