use of ch.elexis.core.findings.IAllergyIntolerance in project elexis-server by elexis.
the class AllergyIntoleranceResourceProvider method createAllergyIntolerance.
@Create
public MethodOutcome createAllergyIntolerance(@ResourceParam AllergyIntolerance allergyIntolerance) {
MethodOutcome outcome = new MethodOutcome();
Optional<IAllergyIntolerance> exists = getTransformer().getLocalObject(allergyIntolerance);
if (exists.isPresent()) {
outcome.setCreated(false);
outcome.setId(new IdType(allergyIntolerance.getId()));
} else {
Optional<IAllergyIntolerance> created = getTransformer().createLocalObject(allergyIntolerance);
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.IAllergyIntolerance 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.findings.IAllergyIntolerance in project elexis-server by elexis.
the class AllergyIntoleranceTest method setupClass.
@BeforeClass
public static void setupClass() throws IOException, SQLException {
AllTests.getTestDatabaseInitializer().initializePatient();
client = FhirUtil.getGenericClient("http://localhost:8380/fhir");
assertNotNull(client);
IAllergyIntolerance allergyIntolerance = AllTests.getFindingsService().create(IAllergyIntolerance.class);
allergyIntolerance.setText("Allergy Intolerance test 1");
allergyIntolerance.setPatientId(AllTests.getTestDatabaseInitializer().getPatient().getId());
AllTests.getFindingsService().saveFinding(allergyIntolerance);
}
Aggregations