use of ch.elexis.core.findings.IFamilyMemberHistory in project elexis-server by elexis.
the class FamilyMemberHistoryResourceProvider method createFamilyMemberHistory.
@Create
public MethodOutcome createFamilyMemberHistory(@ResourceParam FamilyMemberHistory familyMemberHistory) {
MethodOutcome outcome = new MethodOutcome();
Optional<IFamilyMemberHistory> exists = getTransformer().getLocalObject(familyMemberHistory);
if (exists.isPresent()) {
outcome.setCreated(false);
outcome.setId(new IdType(familyMemberHistory.getId()));
} else {
Optional<IFamilyMemberHistory> created = getTransformer().createLocalObject(familyMemberHistory);
if (created.isPresent()) {
outcome.setCreated(true);
outcome.setId(new IdType(created.get().getId()));
} else {
throw new InternalErrorException("Creation failed");
}
}
return outcome;
}
use of ch.elexis.core.findings.IFamilyMemberHistory in project elexis-server by elexis.
the class FamilyMemberHistoryTest method setupClass.
@BeforeClass
public static void setupClass() throws IOException, SQLException {
AllTests.getTestDatabaseInitializer().initializePatient();
client = FhirUtil.getGenericClient("http://localhost:8380/fhir");
assertNotNull(client);
IFamilyMemberHistory familyMemberHistory = AllTests.getFindingsService().create(IFamilyMemberHistory.class);
familyMemberHistory.setText("Family Member History test 1");
familyMemberHistory.setPatientId(AllTests.getTestDatabaseInitializer().getPatient().getId());
AllTests.getFindingsService().saveFinding(familyMemberHistory);
}
use of ch.elexis.core.findings.IFamilyMemberHistory 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();
}
Aggregations