Search in sources :

Example 1 with PatientEhr

use of org.ehrbase.fhirbridge.core.domain.PatientEhr in project fhir-bridge by ehrbase.

the class EhrStatusService method updateEhrStatus.

@Async
public void updateEhrStatus() throws InterruptedException {
    log.info("--- Start Update Process ---");
    Pageable pageable = PageRequest.of(0, 100);
    Page<PatientEhr> result = null;
    int count = 0;
    while (result == null || result.hasNext()) {
        result = patientEhrRepository.findAll(pageable);
        pageable = result.getPageable().next();
        for (var patientEhr : result) {
            handlePatient(patientEhr);
            log.info("Processing: {}/{}", ++count, result.getTotalElements());
        }
    }
    log.info("--- Update Process Completed ---");
}
Also used : Pageable(org.springframework.data.domain.Pageable) EhrEndpoint(org.ehrbase.client.openehrclient.EhrEndpoint) PatientEhr(org.ehrbase.fhirbridge.core.domain.PatientEhr) Async(org.springframework.scheduling.annotation.Async)

Example 2 with PatientEhr

use of org.ehrbase.fhirbridge.core.domain.PatientEhr in project fhir-bridge by ehrbase.

the class EhrLookupProcessor method createEhr.

/**
 * Creates an EHR for the given patient ID.
 *
 * @param patientId the given patient ID
 * @return the EHR ID
 */
private UUID createEhr(IIdType patientId) {
    Patient patient = patientDao.read(patientId);
    Identifier pseudonym = PatientUtils.getPseudonym(patient);
    PartySelf subject = new PartySelf(new PartyRef(new HierObjectId(pseudonym.getValue()), "DEMOGRAPHIC", "PERSON"));
    EhrStatus ehrStatus = new EhrStatus(ARCHETYPE_NODE_ID, new DvText("EHR Status"), subject, true, true, null);
    UUID ehrId = openEhrClient.ehrEndpoint().createEhr(ehrStatus);
    PatientEhr patientEhr = new PatientEhr(patientId.getIdPart(), ehrId);
    patientEhrRepository.save(patientEhr);
    LOG.debug("Created PatientEhr: patientId={}, ehrId={}", patientEhr.getPatientId(), patientEhr.getEhrId());
    return ehrId;
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) Identifier(org.hl7.fhir.r4.model.Identifier) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) Patient(org.hl7.fhir.r4.model.Patient) UUID(java.util.UUID) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) PatientEhr(org.ehrbase.fhirbridge.core.domain.PatientEhr)

Aggregations

PatientEhr (org.ehrbase.fhirbridge.core.domain.PatientEhr)2 DvText (com.nedap.archie.rm.datavalues.DvText)1 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)1 PartySelf (com.nedap.archie.rm.generic.PartySelf)1 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)1 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)1 UUID (java.util.UUID)1 EhrEndpoint (org.ehrbase.client.openehrclient.EhrEndpoint)1 Identifier (org.hl7.fhir.r4.model.Identifier)1 Patient (org.hl7.fhir.r4.model.Patient)1 Pageable (org.springframework.data.domain.Pageable)1 Async (org.springframework.scheduling.annotation.Async)1