Search in sources :

Example 1 with IFamilyMemberHistory

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;
}
Also used : IFamilyMemberHistory(ch.elexis.core.findings.IFamilyMemberHistory) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.r4.model.IdType) Create(ca.uhn.fhir.rest.annotation.Create)

Example 2 with IFamilyMemberHistory

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);
}
Also used : IFamilyMemberHistory(ch.elexis.core.findings.IFamilyMemberHistory) BeforeClass(org.junit.BeforeClass)

Example 3 with IFamilyMemberHistory

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

Aggregations

IFamilyMemberHistory (ch.elexis.core.findings.IFamilyMemberHistory)3 Create (ca.uhn.fhir.rest.annotation.Create)1 Search (ca.uhn.fhir.rest.annotation.Search)1 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)1 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)1 IPatient (ch.elexis.core.model.IPatient)1 ArrayList (java.util.ArrayList)1 FamilyMemberHistory (org.hl7.fhir.r4.model.FamilyMemberHistory)1 IdType (org.hl7.fhir.r4.model.IdType)1 BeforeClass (org.junit.BeforeClass)1