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