Search in sources :

Example 6 with HierObjectId

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());
}
Also used : InvalidApiParameterException(org.ehrbase.api.exception.InvalidApiParameterException) PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) UUID(java.util.UUID) URI(java.net.URI) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 7 with HierObjectId

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);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) 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 8 with HierObjectId

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;
}
Also used : EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) CompareCanonicalDvDateTime(org.ehrbase.client.openehrclient.defaultrestclient.systematic.comparator.datetime.CompareCanonicalDvDateTime) Map(java.util.Map) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) CompareCanonicalDvDateTime(org.ehrbase.client.openehrclient.defaultrestclient.systematic.comparator.datetime.CompareCanonicalDvDateTime)

Example 9 with HierObjectId

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");
        }
    }
}
Also used : DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) DvText(com.nedap.archie.rm.datavalues.DvText) FeederAudit(com.nedap.archie.rm.archetyped.FeederAudit) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) Map(java.util.Map) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId)

Example 10 with HierObjectId

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;
}
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

HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)22 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)12 DvText (com.nedap.archie.rm.datavalues.DvText)8 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)7 PartySelf (com.nedap.archie.rm.generic.PartySelf)7 UUID (java.util.UUID)7 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)6 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)5 ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)5 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)4 Composition (com.nedap.archie.rm.composition.Composition)3 VersionedEhrStatus (com.nedap.archie.rm.ehr.VersionedEhrStatus)3 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)3 SdkException (org.ehrbase.util.exception.SdkException)3 Test (org.junit.Test)3 OriginalVersion (com.nedap.archie.rm.changecontrol.OriginalVersion)2 VersionedComposition (com.nedap.archie.rm.ehr.VersionedComposition)2 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)2 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)2 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)2