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