use of com.nedap.archie.rm.support.identification.HierObjectId in project ehrbase by ehrbase.
the class EhrController method createEhr.
@PostMapping
@ResponseStatus(value = HttpStatus.CREATED)
public // overwrites default 200, fixes the wrong listing of 200 in swagger-ui (EHR-56)
ResponseEntity<EhrResponseData> createEhr(@RequestParam(value = "subjectId", required = false) String subjectId, @RequestParam(value = "subjectNamespace", required = false) String subjectNamespace, @RequestParam(value = "committerId", required = false) String committerId, @RequestParam(value = "committerName", required = false) String committerName, @RequestHeader(value = "Content-Type", required = false) String contentType, @RequestBody(required = false) String content) {
// subjectId and subjectNamespace are not required by EhrScape spec but without those parameters a 400 error shall be returned
if ((subjectId == null) || (subjectNamespace == null)) {
throw new InvalidApiParameterException("subjectId or subjectNamespace missing");
} else if ((subjectId.isEmpty()) || (subjectNamespace.isEmpty())) {
throw new InvalidApiParameterException("subjectId or subjectNamespace emtpy");
}
EhrStatus ehrStatus = extractEhrStatus(content);
PartySelf partySelf = new PartySelf(new PartyRef(new HierObjectId(subjectId), subjectNamespace, null));
ehrStatus.setSubject(partySelf);
UUID ehrId = ehrService.create(ehrStatus, null);
// TODO: use config file or alike to set the basic api path
URI url = URI.create(getBaseEnvLinkURL() + "/rest/ecis/v1/ehr/" + ehrId.toString());
return Optional.ofNullable(ehrId).flatMap(i -> buildEhrResponseData(i, Action.CREATE, contentType)).map(ResponseEntity.created(url)::body).orElse(ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build());
}
use of com.nedap.archie.rm.support.identification.HierObjectId in project openEHR_SDK by ehrbase.
the class DefaultRestEhrFieldsEndpointIT method testCreateEhrWithStatus.
@Test
public void testCreateEhrWithStatus() {
EhrStatus ehrStatus = new EhrStatus();
ehrStatus.setQueryable(false);
ehrStatus.setModifiable(false);
HierObjectId subjectId = new HierObjectId(UUID.randomUUID().toString());
ehrStatus.setSubject(new PartySelf(new PartyRef(subjectId, "default", "PERSON")));
ehrStatus.setArchetypeNodeId("just-a-status");
ehrStatus.setName(new DvText("Status"));
ehr = openEhrClient.ehrEndpoint().createEhr(ehrStatus);
assertThat(ehr).isNotNull();
EhrStatus actual = openEhrClient.ehrEndpoint().getEhrStatus(ehr).get();
assertThat(actual.getSubject().getExternalRef().getId()).isEqualTo(subjectId);
}
use of com.nedap.archie.rm.support.identification.HierObjectId in project openEHR_SDK by ehrbase.
the class EhrComparator method compare.
public Object compare(Map<String, Object> actualEhrMap) {
String type = (String) actualEhrMap.get("_type");
HierObjectId ehrId = (HierObjectId) toRmObject((Map<String, Object>) actualEhrMap.get("ehr_id"), HierObjectId.class);
EhrStatus ehrStatus = (EhrStatus) toRmObject((Map<String, Object>) actualEhrMap.get("ehr_status"), EhrStatus.class);
HierObjectId systemId = (HierObjectId) toRmObject((Map<String, Object>) actualEhrMap.get("system_id"), HierObjectId.class);
DvDateTime timeCreated = (DvDateTime) toRmObject((Map<String, Object>) actualEhrMap.get("time_created"), DvDateTime.class);
// high level attributes
assertThat(type).isEqualTo("EHR");
new CompareCanonicalHierObjects(ehrId).isExpectedEqualToCanonicalUsing(ehrUUID.toString());
new CompareCanonicalHierObjects(systemId).isExpectedEqualToCanonicalUsing("local.ehrbase.org");
new CompareCanonicalDvDateTime(timeCreated).setCompareDateOnly(true).isExpectedEqualToCanonicalUsing(transactionDateTime);
EhrStatusComparator.compare(ehrStatus, referenceEhrStatus);
return null;
}
use of com.nedap.archie.rm.support.identification.HierObjectId in project openEHR_SDK by ehrbase.
the class LocatableUnmarshalPostprocessor method process.
/**
* {@inheritDoc} Unmarshalls {@link Composition#setUid}
*/
@Override
public void process(String term, Locatable rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
if (RmConstants.ELEMENT.equals(context.getNodeDeque().peek().getRmType()) || !context.getFlatHelper().skip(context)) {
setValue(term + PATH_DIVIDER + "_uid", null, values, s -> rmObject.setUid(new HierObjectId(s)), String.class, consumedPaths);
Map<Integer, Map<String, String>> links = extractMultiValued(term, "_link", values);
if (rmObject.getLinks() == null) {
rmObject.setLinks(new ArrayList<>());
}
rmObject.getLinks().addAll(links.values().stream().map(DefaultValues::createLink).collect(Collectors.toList()));
consumeAllMatching(term + PATH_DIVIDER + "_link", values, consumedPaths, false);
Map<FlatPathDto, String> feederAuditValues = FlatHelper.filter(values, term + "/_feeder_audit", false);
if (!feederAuditValues.isEmpty()) {
rmObject.setFeederAudit(new FeederAudit());
handleRmAttribute(term, rmObject.getFeederAudit(), feederAuditValues, consumedPaths, context, "feeder_audit");
}
Map<FlatPathDto, String> nameValues = FlatHelper.filter(values, term + "/_name", false);
if (!nameValues.isEmpty()) {
final DvText name;
boolean isDvCodedText = nameValues.keySet().stream().anyMatch(e -> "code".equals(e.getLast().getAttributeName()) && "_name".equals(e.getLast().getName()));
if (isDvCodedText) {
name = new DvCodedText();
} else {
name = new DvText();
}
rmObject.setName(name);
handleRmAttribute(term, rmObject.getName(), nameValues, consumedPaths, context, "name");
}
}
}
use of com.nedap.archie.rm.support.identification.HierObjectId 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;
}
Aggregations