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