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();
}
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;
}
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();
}
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);
}
Aggregations