Search in sources :

Example 11 with IPatient

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

the class ConditionResourceProvider method findCondition.

@Search()
public List<Condition> findCondition(@RequiredParam(name = Condition.SP_SUBJECT) IdType thePatientId, @OptionalParam(name = Condition.SP_CATEGORY) CodeType categoryCode) {
    if (thePatientId != null && !thePatientId.isEmpty()) {
        Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
        if (patient.isPresent()) {
            if (patient.get().isPatient()) {
                // migrate diagnose condition first
                migratorService.migratePatientsFindings(thePatientId.getIdPart(), ICondition.class, null);
                List<ICondition> findings = findingsService.getPatientsFindings(thePatientId.getIdPart(), ICondition.class);
                if (findings != null && !findings.isEmpty()) {
                    List<Condition> ret = new ArrayList<Condition>();
                    for (ICondition iFinding : findings) {
                        if (categoryCode != null && !isConditionCategory(iFinding, categoryCode)) {
                            continue;
                        }
                        Optional<Condition> fhirEncounter = getTransformer().getFhirObject(iFinding);
                        fhirEncounter.ifPresent(fe -> ret.add(fe));
                    }
                    return ret;
                }
            }
        }
    }
    return Collections.emptyList();
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) ICondition(ch.elexis.core.findings.ICondition) ArrayList(java.util.ArrayList) IPatient(ch.elexis.core.model.IPatient) ICondition(ch.elexis.core.findings.ICondition) Search(ca.uhn.fhir.rest.annotation.Search)

Example 12 with IPatient

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

the class EncounterResourceProvider method searchReqPatientOptDate.

/**
 * Search for all encounters by the patient id. Optional the date range of the returned
 * encounters can be specified.
 *
 * @param thePatientId
 * @param dates
 * @return
 */
@Search
public List<Encounter> searchReqPatientOptDate(@RequiredParam(name = Encounter.SP_PATIENT) IdType thePatientId, @OptionalParam(name = Encounter.SP_DATE) DateRangeParam dates, @IncludeParam(allow = { "Encounter.diagnosis" }) Set<Include> theIncludes) {
    if (thePatientId != null && !thePatientId.isEmpty()) {
        Optional<IPatient> patient = coreModelService.load(thePatientId.getIdPart(), IPatient.class);
        if (patient.isPresent()) {
            if (patient.get().isPatient()) {
                // migrate encounters first
                migratorService.migratePatientsFindings(thePatientId.getIdPart(), IEncounter.class, null);
                List<IEncounter> findings = findingsService.getPatientsFindings(patient.get().getId(), IEncounter.class);
                if (findings != null && !findings.isEmpty()) {
                    List<Encounter> ret = new ArrayList<Encounter>();
                    for (IEncounter iFinding : findings) {
                        Optional<Encounter> fhirEncounter = getTransformer().getFhirObject(iFinding);
                        fhirEncounter.ifPresent(fe -> {
                            if (dates != null) {
                                if (!DateRangeParamUtil.isPeriodInRange(fe.getPeriod(), dates)) {
                                    return;
                                }
                            }
                            ret.add(fe);
                        });
                    }
                    return ret;
                }
            }
        }
    }
    return null;
}
Also used : IEncounter(ch.elexis.core.findings.IEncounter) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.r4.model.Encounter) IEncounter(ch.elexis.core.findings.IEncounter) IPatient(ch.elexis.core.model.IPatient) Search(ca.uhn.fhir.rest.annotation.Search)

Example 13 with IPatient

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

the class FamilyMemberHistoryResourceProvider method findFamilyMemberHistory.

@Search()
public List<FamilyMemberHistory> findFamilyMemberHistory(@RequiredParam(name = FamilyMemberHistory.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<FamilyMemberHistory> ret = new ArrayList<>();
                List<IFamilyMemberHistory> findings = findingsService.getPatientsFindings(patientId.getIdPart(), IFamilyMemberHistory.class);
                if (findings != null && !findings.isEmpty()) {
                    for (IFamilyMemberHistory iFinding : findings) {
                        Optional<FamilyMemberHistory> fhirFamilyMemberHistory = getTransformer().getFhirObject(iFinding);
                        if (fhirFamilyMemberHistory.isPresent()) {
                            ret.add(fhirFamilyMemberHistory.get());
                        }
                    }
                }
                return ret;
            }
        }
    }
    return Collections.emptyList();
}
Also used : FamilyMemberHistory(org.hl7.fhir.r4.model.FamilyMemberHistory) IFamilyMemberHistory(ch.elexis.core.findings.IFamilyMemberHistory) IFamilyMemberHistory(ch.elexis.core.findings.IFamilyMemberHistory) ArrayList(java.util.ArrayList) IPatient(ch.elexis.core.model.IPatient) Search(ca.uhn.fhir.rest.annotation.Search)

Example 14 with IPatient

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

the class AbstractServiceTest method createTestMandantPatientFallBehandlung.

public void createTestMandantPatientFallBehandlung() {
    TimeTool timeTool = new TimeTool();
    IPerson mandator = new IContactBuilder.PersonBuilder(modelService, "mandator1 " + timeTool.toString(), "Anton" + timeTool.toString(), timeTool.toLocalDate(), Gender.MALE).mandator().buildAndSave();
    mandator.setMandator(true);
    testContacts.add(mandator);
    IPatient patient = new IContactBuilder.PatientBuilder(modelService, "Armer", "Anton" + timeTool.toString(), timeTool.toLocalDate(), Gender.MALE).buildAndSave();
    testPatients.add(patient);
    ICoverage testFall = new ICoverageBuilder(modelService, patient, "Fallbezeichnung", "Fallgrund", "KVG").buildAndSave();
    testFaelle.add(testFall);
    IEncounter behandlung = new IEncounterBuilder(modelService, testFall, (IMandator) mandator).buildAndSave();
    testBehandlungen.add(behandlung);
}
Also used : IPerson(ch.elexis.core.model.IPerson) IEncounter(ch.elexis.core.model.IEncounter) IContactBuilder(ch.elexis.core.model.builder.IContactBuilder) ICoverage(ch.elexis.core.model.ICoverage) IMandator(ch.elexis.core.model.IMandator) ICoverageBuilder(ch.elexis.core.model.builder.ICoverageBuilder) TimeTool(ch.rgw.tools.TimeTool) IEncounterBuilder(ch.elexis.core.model.builder.IEncounterBuilder) IPatient(ch.elexis.core.model.IPatient)

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