Search in sources :

Example 1 with IEncounter

use of ch.elexis.core.findings.IEncounter in project elexis-server by elexis.

the class EncounterResourceProvider method searchReqIdentifier.

/**
 * Search for an Encounter with a matching Elexis consultation id.
 *
 * @param identifier
 * @return
 */
@Search
public List<Encounter> searchReqIdentifier(@RequiredParam(name = Encounter.SP_IDENTIFIER) TokenParam identifier) {
    if (identifier != null && !identifier.isEmpty() && identifier.getValue() != null && !identifier.getValue().isEmpty()) {
        migratorService.migrateConsultationsFindings(identifier.getValue(), IEncounter.class);
        List<IEncounter> findings = findingsService.getConsultationsFindings(identifier.getValue(), IEncounter.class);
        if (findings != null && !findings.isEmpty()) {
            List<Encounter> ret = new ArrayList<Encounter>();
            for (IFinding iFinding : findings) {
                Optional<Encounter> fhirEncounter = getTransformer().getFhirObject((IEncounter) iFinding);
                fhirEncounter.ifPresent(fe -> ret.add(fe));
            }
            return ret;
        }
    }
    return null;
}
Also used : IEncounter(ch.elexis.core.findings.IEncounter) IFinding(ch.elexis.core.findings.IFinding) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.r4.model.Encounter) IEncounter(ch.elexis.core.findings.IEncounter) Search(ca.uhn.fhir.rest.annotation.Search)

Example 2 with IEncounter

use of ch.elexis.core.findings.IEncounter in project elexis-server by elexis.

the class ObservationTest method setupClass.

@BeforeClass
public static void setupClass() throws IOException, SQLException, ElexisException {
    AllTests.getTestDatabaseInitializer().initializeLabResult();
    AllTests.getTestDatabaseInitializer().initializeBehandlung();
    AllTests.getTestDatabaseInitializer().initializeMandant();
    client = FhirUtil.getGenericClient("http://localhost:8380/fhir");
    assertNotNull(client);
    IObservation persAnam = AllTests.getFindingsService().create(IObservation.class);
    persAnam.setCategory(ObservationCategory.SOCIALHISTORY);
    persAnam.setCoding(Collections.singletonList(new TransientCoding(ObservationCode.ANAM_PERSONAL)));
    persAnam.setText("Pers Anamnese 1");
    persAnam.setPatientId(AllTests.getTestDatabaseInitializer().getPatient().getId());
    IObservation risk = AllTests.getFindingsService().create(IObservation.class);
    risk.setCategory(ObservationCategory.SOCIALHISTORY);
    risk.setCoding(Collections.singletonList(new TransientCoding(ObservationCode.ANAM_RISK)));
    risk.setText("Risiken 1");
    risk.setPatientId(AllTests.getTestDatabaseInitializer().getPatient().getId());
    IEncounter encounter = AllTests.getFindingsService().create(IEncounter.class);
    encounter.setConsultationId(TestDatabaseInitializer.getBehandlung().getId());
    encounter.setPatientId(AllTests.getTestDatabaseInitializer().getPatient().getId());
    IObservation iObservation = AllTests.getFindingsService().create(IObservation.class);
    iObservation.setCategory(ObservationCategory.SOAP_SUBJECTIVE);
    iObservation.setText("Encounter test 1");
    iObservation.setPatientId(AllTests.getTestDatabaseInitializer().getPatient().getId());
    iObservation.setEncounter(encounter);
    IObservation vitalSign = AllTests.getFindingsService().create(IObservation.class);
    vitalSign.setObservationType(ObservationType.COMP);
    vitalSign.setCategory(ObservationCategory.VITALSIGNS);
    vitalSign.setCoding(Collections.singletonList(new TransientCoding(CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem(), "test", "display test")));
    ObservationComponent componentA = new ObservationComponent("componentA");
    componentA.setNumericValue(new BigDecimal("122"));
    componentA.setNumericValueUnit("mmHg");
    vitalSign.addComponent(componentA);
    ObservationComponent componentB = new ObservationComponent("componentB");
    componentB.setNumericValue(new BigDecimal("78"));
    componentB.setNumericValueUnit("mmHg");
    vitalSign.addComponent(componentB);
    vitalSign.setPatientId(AllTests.getTestDatabaseInitializer().getPatient().getId());
    vitalSign.setEncounter(encounter);
    new UpdateFindingTextCommand(vitalSign).execute();
    AllTests.getFindingsService().saveFinding(persAnam);
    AllTests.getFindingsService().saveFinding(risk);
    AllTests.getFindingsService().saveFinding(encounter);
    AllTests.getFindingsService().saveFinding(iObservation);
    AllTests.getFindingsService().saveFinding(vitalSign);
    findingsCreated.add(persAnam);
    findingsCreated.add(risk);
    findingsCreated.add(encounter);
    findingsCreated.add(iObservation);
    findingsCreated.add(vitalSign);
}
Also used : IEncounter(ch.elexis.core.findings.IEncounter) TransientCoding(ch.elexis.core.findings.util.model.TransientCoding) UpdateFindingTextCommand(ch.elexis.core.findings.util.commands.UpdateFindingTextCommand) BigDecimal(java.math.BigDecimal) IObservation(ch.elexis.core.findings.IObservation) ObservationComponent(ch.elexis.core.findings.ObservationComponent) BeforeClass(org.junit.BeforeClass)

Example 3 with IEncounter

use of ch.elexis.core.findings.IEncounter in project elexis-server by elexis.

the class ServiceRequestResourceProvider method findProcedureRequest.

@Search()
public List<ServiceRequest> findProcedureRequest(@RequiredParam(name = ServiceRequest.SP_PATIENT) IdType thePatientId, @OptionalParam(name = ServiceRequest.SP_ENCOUNTER) IdType theEncounterId) {
    if (thePatientId != null && !thePatientId.isEmpty()) {
        Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
        if (patient.isPresent()) {
            if (patient.get().isPatient()) {
                List<IProcedureRequest> findings = findingsService.getPatientsFindings(thePatientId.getIdPart(), IProcedureRequest.class);
                if (theEncounterId != null) {
                    Optional<IEncounter> encounter = findingsService.findById(theEncounterId.getIdPart(), IEncounter.class);
                    if (encounter.isPresent()) {
                        IEncounter iEncounter = encounter.get();
                        String consid = iEncounter.getConsultationId();
                        if (consid != null && !consid.isEmpty()) {
                            findings = findingsService.getConsultationsFindings(consid, IProcedureRequest.class);
                        }
                    }
                }
                if (findings != null && !findings.isEmpty()) {
                    List<ServiceRequest> ret = new ArrayList<ServiceRequest>();
                    for (IProcedureRequest iFinding : findings) {
                        Optional<ServiceRequest> fhirProcedureRequest = getTransformer().getFhirObject(iFinding);
                        fhirProcedureRequest.ifPresent(pr -> ret.add(pr));
                    }
                    return ret;
                }
            }
        }
    }
    return Collections.emptyList();
}
Also used : IProcedureRequest(ch.elexis.core.findings.IProcedureRequest) IEncounter(ch.elexis.core.findings.IEncounter) ArrayList(java.util.ArrayList) IPatient(ch.elexis.core.model.IPatient) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Search(ca.uhn.fhir.rest.annotation.Search)

Example 4 with IEncounter

use of ch.elexis.core.findings.IEncounter in project elexis-server by elexis.

the class MigratorService method migrateEncounter.

private void migrateEncounter(ch.elexis.core.model.IEncounter encounter) {
    IPatient patient = encounter.getCoverage().getPatient();
    IQuery<IEncounter> query = FindingsModelServiceHolder.get().getQuery(IEncounter.class);
    query.and("patientid", COMPARATOR.EQUALS, patient.getId());
    query.and("consultationid", COMPARATOR.EQUALS, encounter.getId());
    List<IEncounter> encounters = query.execute();
    if (encounters.isEmpty()) {
        createEncounter(encounter);
    }
}
Also used : IEncounter(ch.elexis.core.findings.IEncounter) IPatient(ch.elexis.core.model.IPatient)

Example 5 with IEncounter

use of ch.elexis.core.findings.IEncounter in project elexis-server by elexis.

the class MigratorService method createEncounter.

private void createEncounter(ch.elexis.core.model.IEncounter encounter) {
    IEncounter findingsEncounter = FindingsServiceHolder.getiFindingsService().create(IEncounter.class);
    updateEncounter(findingsEncounter, encounter);
}
Also used : IEncounter(ch.elexis.core.findings.IEncounter)

Aggregations

IEncounter (ch.elexis.core.findings.IEncounter)6 Search (ca.uhn.fhir.rest.annotation.Search)3 IPatient (ch.elexis.core.model.IPatient)3 ArrayList (java.util.ArrayList)3 Encounter (org.hl7.fhir.r4.model.Encounter)2 IFinding (ch.elexis.core.findings.IFinding)1 IObservation (ch.elexis.core.findings.IObservation)1 IProcedureRequest (ch.elexis.core.findings.IProcedureRequest)1 ObservationComponent (ch.elexis.core.findings.ObservationComponent)1 UpdateFindingTextCommand (ch.elexis.core.findings.util.commands.UpdateFindingTextCommand)1 TransientCoding (ch.elexis.core.findings.util.model.TransientCoding)1 BigDecimal (java.math.BigDecimal)1 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)1 BeforeClass (org.junit.BeforeClass)1