Search in sources :

Example 1 with PartyRef

use of com.nedap.archie.rm.support.identification.PartyRef in project fhir-bridge by ehrbase.

the class EhrController method createEHR.

@PostMapping
public ResponseEntity<String> createEHR(@RequestParam String pPatientId) {
    try {
        // taken from EhrBase tests
        PartySelf subject = new PartySelf();
        PartyRef externalRef = new PartyRef();
        externalRef.setType("PARTY_REF");
        externalRef.setNamespace("patients");
        GenericId genericId = new GenericId();
        genericId.setScheme("id_scheme");
        genericId.setValue(pPatientId);
        externalRef.setId(genericId);
        subject.setExternalRef(externalRef);
        DvText dvText = new DvText("any EHR status");
        EhrStatus ehrStatus = new EhrStatus("openEHR-EHR-ITEM_TREE.generic.v1", dvText, subject, true, true, null);
        return ResponseEntity.ok(openEhrClient.ehrEndpoint().createEhr(ehrStatus).toString());
    } catch (Exception ex) {
        return new ResponseEntity<>("Error while creating an EHR for patient id " + pPatientId, HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) GenericId(com.nedap.archie.rm.support.identification.GenericId) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with PartyRef

use of com.nedap.archie.rm.support.identification.PartyRef in project fhir-bridge by ehrbase.

the class AbstractSetupIT method setup.

@BeforeAll
static void setup() throws URISyntaxException {
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("myuser", "myPassword432"));
    CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build();
    DefaultRestClient client = new DefaultRestClient(new OpenEhrClientConfig(new URI("http://localhost:8080/ehrbase/")), new ResourceTemplateProvider("classpath:/opt/*.opt"), httpClient);
    PATIENT_ID = UUID.randomUUID().toString();
    EhrStatus ehrStatus = new EhrStatus();
    ehrStatus.setSubject(new PartySelf(new PartyRef(new HierObjectId(PATIENT_ID), "demographic", "PERSON")));
    ehrStatus.setArchetypeNodeId("openEHR-EHR-EHR_STATUS.generic.v1");
    ehrStatus.setName(new DvText("Integration tests status"));
    client.ehrEndpoint().createEhr(ehrStatus);
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) DefaultRestClient(org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient) URI(java.net.URI) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) PartyRef(com.nedap.archie.rm.support.identification.PartyRef) OpenEhrClientConfig(org.ehrbase.client.openehrclient.OpenEhrClientConfig) ResourceTemplateProvider(org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with PartyRef

use of com.nedap.archie.rm.support.identification.PartyRef in project ehrbase by ehrbase.

the class PersistedPartySelf method render.

@Override
public PartyProxy render(PartyIdentifiedRecord partyIdentifiedRecord) {
    PartyRef partyRef = null;
    if (partyIdentifiedRecord.getPartyRefType() != null) {
        ObjectId objectID = new PersistedObjectId().fromDB(partyIdentifiedRecord);
        partyRef = new PartyRef(objectID, partyIdentifiedRecord.getPartyRefNamespace(), partyIdentifiedRecord.getPartyRefType());
    }
    return new PartySelf(partyRef);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf)

Example 4 with PartyRef

use of com.nedap.archie.rm.support.identification.PartyRef in project ehrbase by ehrbase.

the class PartyRefValue method attributes.

/**
 * extract the attributes of party_ref
 * @return
 */
PartyRefValue attributes() {
    if (// PartySelf f.e.
    partyProxy.getExternalRef() == null)
        return this;
    PartyRef partyRef = partyProxy.getExternalRef();
    namespace = partyRef != null ? partyRef.getNamespace() : null;
    ObjectId objectId = partyRef.getId();
    value = objectId != null ? objectId.getValue() : null;
    if (objectId != null && objectId instanceof GenericId)
        scheme = ((GenericId) objectId).getScheme();
    type = partyRef != null ? partyRef.getType() : null;
    objectIdType = partyRef != null ? PartyRefIdType.valueOf(new PersistedObjectId().objectIdClassSnakeCase(partyRef)) : PartyRefIdType.undefined;
    return this;
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) GenericId(com.nedap.archie.rm.support.identification.GenericId) ObjectId(com.nedap.archie.rm.support.identification.ObjectId)

Example 5 with PartyRef

use of com.nedap.archie.rm.support.identification.PartyRef 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)

Aggregations

PartyRef (com.nedap.archie.rm.support.identification.PartyRef)19 DvText (com.nedap.archie.rm.datavalues.DvText)9 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)8 PartySelf (com.nedap.archie.rm.generic.PartySelf)8 GenericId (com.nedap.archie.rm.support.identification.GenericId)8 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)7 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)6 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)5 Test (org.junit.Test)4 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)3 EventContext (com.nedap.archie.rm.composition.EventContext)2 ItemTree (com.nedap.archie.rm.datastructures.ItemTree)2 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)2 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)2 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)2 Participation (com.nedap.archie.rm.generic.Participation)2 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)2 URI (java.net.URI)2 UUID (java.util.UUID)2 DateTime (org.joda.time.DateTime)2