Search in sources :

Example 16 with EhrStatus

use of com.nedap.archie.rm.ehr.EhrStatus 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)

Example 17 with EhrStatus

use of com.nedap.archie.rm.ehr.EhrStatus in project openEHR_SDK by ehrbase.

the class DefaultRestEhrFieldsEndpointIT method testUpdateEhrStatus.

@Test
public void testUpdateEhrStatus() throws IOException {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    EhrStatus ehrStatus = openEhrClient.ehrEndpoint().getEhrStatus(ehr).get();
    ehrStatus.setQueryable(false);
    ehrStatus.setModifiable(false);
    HierObjectId subjectId = new HierObjectId("6ee110de-08f8-4fac-8372-820650f150a9");
    ehrStatus.setSubject(new PartySelf(new PartyRef(subjectId, "default", "PERSON")));
    String value = IOUtils.toString(ItemStruktureTestDataCanonicalJson.SIMPLE_EHR_OTHER_Details.getStream(), UTF_8);
    ehrStatus.setOtherDetails(new CanonicalJson().unmarshal(value, ItemTree.class));
    ehrStatus.getOtherDetails().setArchetypeNodeId("other-details-test");
    ehrStatus.getOtherDetails().setName(new DvText("test"));
    openEhrClient.ehrEndpoint().updateEhrStatus(ehr, ehrStatus);
    EhrStatus actual = openEhrClient.ehrEndpoint().getEhrStatus(ehr).get();
    assertThat(actual.getSubject().getExternalRef().getId()).isEqualTo(subjectId);
    assertThat(actual.isModifiable()).isEqualTo(ehrStatus.isModifiable());
    assertThat(actual.isQueryable()).isEqualTo(ehrStatus.isQueryable());
    assertThat(actual.getOtherDetails()).isNotNull();
    assertThat(actual.getOtherDetails().getItems()).size().isEqualTo(ehrStatus.getOtherDetails().getItems().size());
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) ItemStruktureTestDataCanonicalJson(org.ehrbase.test_data.item_structure.ItemStruktureTestDataCanonicalJson) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) ItemTree(com.nedap.archie.rm.datastructures.ItemTree) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Example 18 with EhrStatus

use of com.nedap.archie.rm.ehr.EhrStatus in project openEHR_SDK by ehrbase.

the class CanonicalEhrQuery3IT method testEhrAutoWhere.

@Test
public void testEhrAutoWhere() throws IOException {
    EhrStatus referenceEhrStatus = new CanonicalJson().unmarshal(IOUtils.toString(EhrTestDataCanonicalJson.EHR_STATUS_SUBJECT_EXTERNAL_REF_OTHER_DETAILS.getStream(), StandardCharsets.UTF_8), EhrStatus.class);
    String rootPath = "e/ehr_status";
    RMObject referenceNode = referenceEhrStatus;
    String csvTestSet = dirPath + "/testEhrStatusWhere.csv";
    assertThat(new AutoEhrStatusWhereQuery(ehrUUID, openEhrClient).testItemPaths(csvTestSet, rootPath, referenceNode)).isTrue();
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) EhrTestDataCanonicalJson(org.ehrbase.test_data.ehr.EhrTestDataCanonicalJson) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) AutoEhrStatusWhereQuery(org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoEhrStatusWhereQuery) RMObject(com.nedap.archie.rm.RMObject)

Example 19 with EhrStatus

use of com.nedap.archie.rm.ehr.EhrStatus in project openEHR_SDK by ehrbase.

the class ItemStructureVisitorTest method ehrVisitorTest.

@Test
public void ehrVisitorTest() throws Throwable {
    String value = IOUtils.toString(ItemStruktureTestDataCanonicalJson.SIMPLE_EHR_OTHER_Details.getStream(), UTF_8);
    RMJacksonConfiguration configuration = new RMJacksonConfiguration();
    configuration.setTypePropertyName("_type");
    ObjectMapper objectMapper = JacksonUtil.getObjectMapper(configuration);
    ItemTree otherDetails = objectMapper.readValue(value, ItemTree.class);
    EhrStatus ehrStatus = new EhrStatus("ehr_status", new DvText("ehr_status"), new PartySelf(new PartyRef()), true, true, otherDetails);
    itemStructureVisitor.validate(ehrStatus);
    assertEquals(3, itemStructureVisitor.getElementOccurrences());
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) ItemTree(com.nedap.archie.rm.datastructures.ItemTree) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RMJacksonConfiguration(com.nedap.archie.json.RMJacksonConfiguration) DvText(com.nedap.archie.rm.datavalues.DvText) PartySelf(com.nedap.archie.rm.generic.PartySelf) Test(org.junit.Test)

Example 20 with EhrStatus

use of com.nedap.archie.rm.ehr.EhrStatus in project ehrbase by ehrbase.

the class StatusAccess method getStatus.

@Override
public EhrStatus getStatus() {
    EhrStatus status = new EhrStatus();
    status.setModifiable(getStatusRecord().getIsModifiable());
    status.setQueryable(getStatusRecord().getIsQueryable());
    // set otherDetails if available
    if (getStatusRecord().getOtherDetails() != null) {
        status.setOtherDetails(getStatusRecord().getOtherDetails());
    }
    // Locatable attribute
    status.setArchetypeNodeId(getStatusRecord().getArchetypeNodeId());
    Object name = new RecordedDvCodedText().fromDB(getStatusRecord(), STATUS.NAME);
    status.setName(name instanceof DvText ? (DvText) name : (DvCodedText) name);
    UUID statusId = getStatusRecord().getId();
    status.setUid(new HierObjectId(statusId.toString() + "::" + getServerConfig().getNodename() + "::" + I_StatusAccess.getLatestVersionNumber(this, statusId)));
    PartySelf partySelf = (PartySelf) new PersistedPartyProxy(this).retrieve(getStatusRecord().getParty());
    status.setSubject(partySelf);
    return status;
}
Also used : EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) RecordedDvCodedText(org.ehrbase.service.RecordedDvCodedText) RecordedDvCodedText(org.ehrbase.service.RecordedDvCodedText) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) UUID(java.util.UUID) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) DvText(com.nedap.archie.rm.datavalues.DvText) PartySelf(com.nedap.archie.rm.generic.PartySelf) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)

Aggregations

EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)23 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)12 UUID (java.util.UUID)11 PartySelf (com.nedap.archie.rm.generic.PartySelf)9 DvText (com.nedap.archie.rm.datavalues.DvText)8 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)7 VersionedEhrStatus (com.nedap.archie.rm.ehr.VersionedEhrStatus)6 InvalidApiParameterException (org.ehrbase.api.exception.InvalidApiParameterException)5 ObjectNotFoundException (org.ehrbase.api.exception.ObjectNotFoundException)5 HttpHeaders (org.springframework.http.HttpHeaders)5 OriginalVersion (com.nedap.archie.rm.changecontrol.OriginalVersion)4 URI (java.net.URI)4 InternalServerException (org.ehrbase.api.exception.InternalServerException)4 Test (org.junit.Test)4 MediaType (org.springframework.http.MediaType)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 Timestamp (java.sql.Timestamp)3 Optional (java.util.Optional)3 EhrService (org.ehrbase.api.service.EhrService)3 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)3