use of org.hl7.fhir.dstu3.model.MessageHeader in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeMessageHeaderMessageHeaderResponseComponent.
protected void composeMessageHeaderMessageHeaderResponseComponent(Complex parent, String parentType, String name, MessageHeader.MessageHeaderResponseComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "response", name, element, index);
if (element.hasIdentifierElement())
composeId(t, "MessageHeader", "identifier", element.getIdentifierElement(), -1);
if (element.hasCodeElement())
composeEnum(t, "MessageHeader", "code", element.getCodeElement(), -1);
if (element.hasDetails())
composeReference(t, "MessageHeader", "details", element.getDetails(), -1);
}
use of org.hl7.fhir.dstu3.model.MessageHeader in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EhrExtractMessageHandlerTest method prepareMocks.
@SneakyThrows
private void prepareMocks(InboundMessage inboundMessage) {
inboundMessage.setPayload("payload");
Bundle bundle = new Bundle();
bundle.setId("Test");
inboundMessage.setPayload(readInboundMessagePayloadFromFile());
inboundMessage.setEbXML(readInboundMessageEbXmlFromFile());
inboundMessage.setAttachments(new ArrayList<>());
inboundMessage.setExternalAttachments(new ArrayList<>());
prepareMigrationRequestAndMigrationStatusMocks();
// imported from main on merge
when(fhirParser.encodeToJson(bundle)).thenReturn(BUNDLE_STRING);
when(objectMapper.writeValueAsString(inboundMessage)).thenReturn(INBOUND_MESSAGE_STRING);
when(bundleMapperService.mapToBundle(any(RCMRIN030000UK06Message.class), eq(LOSING_ODE_CODE))).thenReturn(bundle);
when(attachmentReferenceUpdaterService.updateReferenceToAttachment(inboundMessage.getAttachments(), CONVERSATION_ID, inboundMessage.getPayload())).thenReturn(inboundMessage.getPayload());
when(xPathService.parseDocumentFromXml(inboundMessage.getEbXML())).thenReturn(ebXmlDocument);
when(xPathService.getNodeValue(ebXmlDocument, "/Envelope/Header/MessageHeader/MessageData/MessageId")).thenReturn("6E242658-3D8E-11E3-A7DC-172BDA00FA67");
}
use of org.hl7.fhir.dstu3.model.MessageHeader in project MobileAccessGateway by i4mi.
the class Iti93ResponseConverter method translateToFhir.
/**
* translate ITI-44 response to ITI-93 response
*/
public Bundle translateToFhir(byte[] input, Map<String, Object> parameters) {
try {
// FIX for xmlns:xmlns
String content = new String(input);
content = content.replace("xmlns:xmlns", "xmlns:xxxxx");
MCCIIN000002UV01Type msg = HL7V3Transformer.unmarshallMessage(MCCIIN000002UV01Type.class, new ByteArrayInputStream(content.getBytes()));
Bundle responseBundle = new Bundle().setType(Bundle.BundleType.MESSAGE);
Bundle requestBundle = (Bundle) parameters.get(Utils.KEPT_BODY);
MessageHeader header = (MessageHeader) requestBundle.getEntryFirstRep().getResource();
MessageSourceComponent source = new MessageSourceComponent();
source.setEndpoint(config.getBaseurl());
header.setSource(source);
MessageHeaderResponseComponent response = new MessageHeaderResponseComponent();
response.setCode(ResponseType.OK);
for (net.ihe.gazelle.hl7v3.mccimt000200UV01.MCCIMT000200UV01Acknowledgement akk : msg.getAcknowledgement()) {
CS code = akk.getTypeCode();
if (!code.getCode().equals("AA") && !code.getCode().equals("CA")) {
response.setCode(ResponseType.FATALERROR);
OperationOutcome outcome = new OperationOutcome();
response.setDetails((Reference) new Reference().setResource(outcome));
for (MCCIMT000200UV01AcknowledgementDetail detail : akk.getAcknowledgementDetail()) {
OperationOutcomeIssueComponent issue = outcome.addIssue();
issue.setDetails(new CodeableConcept().setText(toText(detail.getText())).addCoding(transform(detail.getCode())));
}
}
}
response.setIdentifier(header.getId());
header.setId((String) null);
header.setResponse(response);
header.setFocus(null);
BundleEntryComponent cmp = responseBundle.addEntry();
cmp.setResource(header);
return responseBundle;
} catch (JAXBException e) {
throw new InvalidRequestException("failed parsing response");
}
}
use of org.hl7.fhir.dstu3.model.MessageHeader in project MobileAccessGateway by i4mi.
the class Iti93UpdateRequestConverter method doUpdate.
public String doUpdate(MessageHeader header, Map<String, BundleEntryComponent> entriesByReference) throws JAXBException {
PRPAIN201302UV02Type resultMsg = new PRPAIN201302UV02Type();
resultMsg.setITSVersion("XML_1.0");
// String UUID.randomUUID().toString();
resultMsg.setId(new II(config.getPixQueryOid(), uniqueId()));
// Now
resultMsg.setCreationTime(new TS(Timestamp.now().toHL7()));
resultMsg.setProcessingCode(new CS("T", null, null));
resultMsg.setProcessingModeCode(new CS("T", null, null));
resultMsg.setInteractionId(new II("2.16.840.1.113883.1.18", "PRPA_IN201302UV02"));
resultMsg.setAcceptAckCode(new CS("AL", null, null));
MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver();
resultMsg.addReceiver(receiver);
receiver.setTypeCode(CommunicationFunctionType.RCV);
MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device();
receiver.setDevice(receiverDevice);
receiverDevice.setClassCode(EntityClassDevice.DEV);
receiverDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
receiverDevice.setId(Collections.singletonList(new II(config.getPixReceiverOid(), null)));
MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender();
resultMsg.setSender(sender);
sender.setTypeCode(CommunicationFunctionType.SND);
MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device();
sender.setDevice(senderDevice);
senderDevice.setClassCode(EntityClassDevice.DEV);
senderDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
senderDevice.setId(Collections.singletonList(new II(config.getPixMySenderOid(), null)));
PRPAIN201302UV02MFMIMT700701UV01ControlActProcess controlActProcess = new PRPAIN201302UV02MFMIMT700701UV01ControlActProcess();
resultMsg.setControlActProcess(controlActProcess);
controlActProcess.setClassCode(ActClassControlAct.CACT);
controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
controlActProcess.setCode(new CD("PRPA_TE201302UV02", "2.16.840.1.113883.1.18", null));
for (BundleEntryComponent entry : entriesByReference.values()) {
if (entry.getResource() instanceof Patient) {
HTTPVerb method = entry.getRequest().getMethod();
if (method == null)
throw new InvalidRequestException("HTTP verb missing in Bundle for Patient resource.");
Patient in = (Patient) entry.getResource();
PRPAIN201302UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201302UV02MFMIMT700701UV01Subject1();
controlActProcess.addSubject(subject);
subject.setTypeCode("SUBJ");
// ???
subject.setContextConductionInd(false);
PRPAIN201302UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201302UV02MFMIMT700701UV01RegistrationEvent();
subject.setRegistrationEvent(registrationEvent);
registrationEvent.setClassCode(ActClass.REG);
registrationEvent.setMoodCode(ActMood.EVN);
// ???
registrationEvent.setStatusCode(new CS("active", null, null));
PRPAIN201302UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201302UV02MFMIMT700701UV01Subject2();
registrationEvent.setSubject1(subject1);
subject1.setTypeCode(ParticipationTargetSubject.SBJ);
PRPAMT201302UV02Patient patient = new PRPAMT201302UV02Patient();
subject1.setPatient(patient);
patient.setClassCode("PAT");
PRPAMT201302UV02PatientStatusCode statusCode = new PRPAMT201302UV02PatientStatusCode();
statusCode.setCode("active");
// ???
patient.setStatusCode(statusCode);
PRPAMT201302UV02PatientPatientPerson patientPerson = new PRPAMT201302UV02PatientPatientPerson();
patient.setPatientPerson(patientPerson);
patientPerson.setClassCode(EntityClass.PSN);
patientPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
patientPerson.setAsOtherIDs(new ArrayList());
List<II> orgIds = new ArrayList<II>();
Set<String> mainIds = new HashSet<String>();
Organization managingOrg = getManagingOrganization(in);
for (Identifier id : managingOrg.getIdentifier()) {
orgIds.add(new II(getScheme(id.getSystem()), null));
mainIds.add(id.getSystem());
}
// TODO How is the correct mapping done?
for (Identifier id : in.getIdentifier()) {
boolean isOwn = mainIds.contains(id.getSystem());
if (isOwn)
patient.addId(patientIdentifierUpd(id));
else {
PRPAMT201302UV02OtherIDs asOtherIDs = new PRPAMT201302UV02OtherIDs();
PRPAMT201302UV02OtherIDsId id2 = new PRPAMT201302UV02OtherIDsId();
id2.setRoot(getScheme(id.getSystem()));
id2.setExtension(id.getValue());
asOtherIDs.setClassCode("PAT");
asOtherIDs.setId(Collections.singletonList(id2));
COCTMT150002UV01Organization scopingOrganization = new COCTMT150002UV01Organization();
scopingOrganization.setClassCode(EntityClassOrganization.ORG);
scopingOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
List<II> scopeOrgIds = new ArrayList<II>();
scopeOrgIds.add(new II(getScheme(id.getSystem()), null));
scopingOrganization.setId(scopeOrgIds);
asOtherIDs.setScopingOrganization(scopingOrganization);
patientPerson.addAsOtherIDs(asOtherIDs);
}
}
for (HumanName name : in.getName()) {
patientPerson.addName(transform(name));
}
patientPerson.setBirthTime(transform(in.getBirthDateElement()));
if (in.hasGender()) {
switch(in.getGender()) {
case MALE:
patientPerson.setAdministrativeGenderCode(new CE("M", "Male", "2.16.840.1.113883.12.1"));
break;
case FEMALE:
patientPerson.setAdministrativeGenderCode(new CE("F", "Female", "2.16.840.1.113883.12.1"));
break;
case OTHER:
patientPerson.setAdministrativeGenderCode(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
break;
case UNKNOWN:
patientPerson.setAdministrativeGenderCode(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
break;
}
}
if (in.hasAddress())
patientPerson.setAddr(new ArrayList<AD>());
for (Address address : in.getAddress()) {
patientPerson.addAddr(transform(address));
}
for (ContactPoint contactPoint : in.getTelecom()) {
patientPerson.addTelecom(transform(contactPoint));
}
if (in.hasDeceasedBooleanType()) {
patientPerson.setDeceasedInd(new BL(in.getDeceasedBooleanType().getValue()));
}
if (in.hasDeceasedDateTimeType()) {
patientPerson.setDeceasedTime(transform(in.getDeceasedDateTimeType()));
}
if (in.hasMultipleBirthBooleanType()) {
patientPerson.setMultipleBirthInd(new BL(in.getMultipleBirthBooleanType().getValue()));
}
if (in.hasMultipleBirthIntegerType()) {
patientPerson.setMultipleBirthOrderNumber(new INT(in.getMultipleBirthIntegerType().getValue()));
}
if (in.hasMaritalStatus()) {
patientPerson.setMaritalStatusCode(transform(in.getMaritalStatus()));
}
if (in.hasCommunication()) {
for (PatientCommunicationComponent pcc : in.getCommunication()) {
PRPAMT201302UV02LanguageCommunication languageCommunication = new PRPAMT201302UV02LanguageCommunication();
languageCommunication.setLanguageCode(transform(pcc.getLanguage()));
if (pcc.hasPreferred())
languageCommunication.setPreferenceInd(new BL(pcc.getPreferred()));
patientPerson.addLanguageCommunication(languageCommunication);
}
}
COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization();
patient.setProviderOrganization(providerOrganization);
providerOrganization.setClassCode(EntityClassOrganization.ORG);
providerOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
providerOrganization.setId(orgIds);
ON name = null;
if (managingOrg.hasName()) {
name = new ON();
name.setMixed(Collections.singletonList(managingOrg.getName()));
providerOrganization.setName(Collections.singletonList(name));
}
COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty();
contactParty.setClassCode(RoleClassContact.CON);
for (ContactPoint contactPoint : managingOrg.getTelecom()) {
contactParty.addTelecom(transform(contactPoint));
}
if (managingOrg.hasAddress())
contactParty.setAddr(new ArrayList<AD>());
for (Address address : managingOrg.getAddress()) {
contactParty.addAddr(transform(address));
}
if (managingOrg.hasContact()) {
OrganizationContactComponent occ = managingOrg.getContactFirstRep();
COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person();
contactPerson.setClassCode(EntityClass.PSN);
contactPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
if (occ.hasName())
contactPerson.setName(Collections.singletonList(transform(occ.getName())));
contactParty.setContactPerson(contactPerson);
}
providerOrganization.setContactParty(Collections.singletonList(contactParty));
MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian();
registrationEvent.setCustodian(custodian);
custodian.setTypeCode(ParticipationType.CST);
COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
custodian.setAssignedEntity(assignedEntity);
assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
List<II> custIds = new ArrayList<II>();
custIds.add(new II(getScheme(config.getCustodianOid()), null));
assignedEntity.setId(custIds);
// assignedEntity.setId(orgIds);
COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization();
assignedEntity.setAssignedOrganization(assignedOrganization);
assignedOrganization.setClassCode(EntityClassOrganization.ORG);
assignedOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
if (managingOrg.hasName()) {
assignedOrganization.setName(Collections.singletonList(name));
}
}
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
HL7V3Transformer.marshallMessage(PRPAIN201302UV02Type.class, out, resultMsg);
String outArray = new String(out.toByteArray());
return outArray;
}
use of org.hl7.fhir.dstu3.model.MessageHeader in project MobileAccessGateway by i4mi.
the class Iti93MergeRequestConverter method doMerge.
/**
* merge request for ITI-93 transaction
* @param header
* @param entriesByReference
* @return
* @throws JAXBException
*/
public String doMerge(MessageHeader header, Map<String, BundleEntryComponent> entriesByReference) throws JAXBException {
PRPAIN201304UV02Type resultMsg = new PRPAIN201304UV02Type();
resultMsg.setITSVersion("XML_1.0");
// String UUID.randomUUID().toString();
resultMsg.setId(new II(config.getPixQueryOid(), uniqueId()));
// Now
resultMsg.setCreationTime(new TS(Timestamp.now().toHL7()));
resultMsg.setProcessingCode(new CS("T", null, null));
resultMsg.setProcessingModeCode(new CS("T", null, null));
resultMsg.setInteractionId(new II("2.16.840.1.113883.1.18", "PRPA_IN201304UV02"));
resultMsg.setAcceptAckCode(new CS("AL", null, null));
MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver();
resultMsg.addReceiver(receiver);
receiver.setTypeCode(CommunicationFunctionType.RCV);
MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device();
receiver.setDevice(receiverDevice);
receiverDevice.setClassCode(EntityClassDevice.DEV);
receiverDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
receiverDevice.setId(Collections.singletonList(new II(config.getPixReceiverOid(), null)));
MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender();
resultMsg.setSender(sender);
sender.setTypeCode(CommunicationFunctionType.SND);
MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device();
sender.setDevice(senderDevice);
senderDevice.setClassCode(EntityClassDevice.DEV);
senderDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
senderDevice.setId(Collections.singletonList(new II(config.getPixMySenderOid(), null)));
PRPAIN201304UV02MFMIMT700701UV01ControlActProcess controlActProcess = new PRPAIN201304UV02MFMIMT700701UV01ControlActProcess();
resultMsg.setControlActProcess(controlActProcess);
// ???
controlActProcess.setClassCode(ActClassControlAct.CACT);
// ???
controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
// ???
controlActProcess.setCode(new CD("PRPA_TE201304UV02", "2.16.840.1.113883.1.18", null));
for (BundleEntryComponent entry : entriesByReference.values()) {
// BundleEntryComponent entry = entriesByReference.get(ref.getReference());
HTTPVerb method = entry.getRequest().getMethod();
if (method == null)
throw new InvalidRequestException("HTTP verb missing in Bundle for Patient resource.");
Patient basePatient = (Patient) entry.getResource();
Patient in = null;
List<Patient> replaced = new ArrayList<Patient>();
for (PatientLinkComponent linked : basePatient.getLink()) {
if (linked.getType().equals(LinkType.REPLACEDBY)) {
Reference other = linked.getOther();
Patient otherPatient = findPatient(other, entriesByReference, basePatient);
in = otherPatient;
replaced.add(basePatient);
} else if (linked.getType().equals(LinkType.REPLACES)) {
Reference other = linked.getOther();
Patient otherPatient = findPatient(other, entriesByReference, basePatient);
in = basePatient;
replaced.add(otherPatient);
}
}
if (in == null || replaced.isEmpty())
throw new InvalidRequestException("Cannot determine Patients to merge");
PRPAIN201304UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201304UV02MFMIMT700701UV01Subject1();
controlActProcess.addSubject(subject);
subject.setTypeCode("SUBJ");
// ???
subject.setContextConductionInd(false);
PRPAIN201304UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201304UV02MFMIMT700701UV01RegistrationEvent();
subject.setRegistrationEvent(registrationEvent);
registrationEvent.setClassCode(ActClass.REG);
registrationEvent.setMoodCode(ActMood.EVN);
// ???
registrationEvent.setStatusCode(new CS("active", null, null));
List<MFMIMT700701UV01ReplacementOf> replacementOfList = new ArrayList<MFMIMT700701UV01ReplacementOf>();
registrationEvent.setReplacementOf(replacementOfList);
for (Patient replacedPatient : replaced) {
MFMIMT700701UV01ReplacementOf replacementOf = new MFMIMT700701UV01ReplacementOf();
MFMIMT700701UV01PriorRegistration priorRegistration = new MFMIMT700701UV01PriorRegistration();
replacementOf.setPriorRegistration(priorRegistration);
replacementOf.setTypeCode("RPLC");
priorRegistration.setClassCode(ActClass.REG);
priorRegistration.setMoodCode(ActMood.EVN);
priorRegistration.setStatusCode(new CS("obsolete", null, null));
MFMIMT700701UV01Subject3 subject1 = new MFMIMT700701UV01Subject3();
priorRegistration.setSubject1(subject1);
subject1.setTypeCode(ParticipationTargetSubject.SBJ);
MFMIMT700701UV01PriorRegisteredRole priorRegisteredRole = new MFMIMT700701UV01PriorRegisteredRole();
subject1.setPriorRegisteredRole(priorRegisteredRole);
priorRegisteredRole.setClassCode("PAT");
for (Identifier id : replacedPatient.getIdentifier()) {
priorRegisteredRole.addId(patientIdentifier(id));
}
replacementOfList.add(replacementOf);
}
PRPAIN201304UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201304UV02MFMIMT700701UV01Subject2();
registrationEvent.setSubject1(subject1);
subject1.setTypeCode(ParticipationTargetSubject.SBJ);
PRPAMT201303UV02Patient patient = new PRPAMT201303UV02Patient();
patient.setClassCode("PAT");
subject1.setPatient(patient);
PRPAMT201302UV02PatientStatusCode statusCode = new PRPAMT201302UV02PatientStatusCode("active", null, null);
// ???
patient.setStatusCode(statusCode);
List<II> orgIds = new ArrayList<II>();
Set<String> mainIds = new HashSet<String>();
PRPAMT201303UV02Person patientPerson = new PRPAMT201303UV02Person();
patientPerson.setClassCode(EntityClass.PSN);
patientPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
patient.setPatientPerson(patientPerson);
Organization managingOrg = getManagingOrganization(in, basePatient.getContained());
for (Identifier id : managingOrg.getIdentifier()) {
orgIds.add(new II(getScheme(id.getSystem()), null));
mainIds.add(id.getSystem());
}
if (managingOrg == null)
managingOrg = getManagingOrganization(basePatient, basePatient.getContained());
if (managingOrg == null)
throw new InvalidRequestException("Cannot determine managingOrganization");
// TODO How is the correct mapping done?
for (Identifier id : in.getIdentifier()) {
PRPAMT201302UV02PatientId patientId = new PRPAMT201302UV02PatientId(getScheme(id.getSystem()), id.getValue());
patient.addId(patientId);
}
for (HumanName name : in.getName()) {
patientPerson.addName(transform(name));
}
COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization();
patient.setProviderOrganization(providerOrganization);
providerOrganization.setClassCode(EntityClassOrganization.ORG);
providerOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
providerOrganization.setId(orgIds);
ON name = null;
if (managingOrg.hasName()) {
name = new ON();
name.setMixed(Collections.singletonList(managingOrg.getName()));
providerOrganization.setName(Collections.singletonList(name));
}
COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty();
contactParty.setClassCode(RoleClassContact.CON);
for (ContactPoint contactPoint : managingOrg.getTelecom()) {
contactParty.addTelecom(transform(contactPoint));
}
if (managingOrg.hasAddress())
contactParty.setAddr(new ArrayList<AD>());
for (Address address : managingOrg.getAddress()) {
contactParty.addAddr(transform(address));
}
if (managingOrg.hasContact()) {
OrganizationContactComponent occ = managingOrg.getContactFirstRep();
COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person();
contactPerson.setClassCode(EntityClass.PSN);
contactPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
if (occ.hasName())
contactPerson.setName(Collections.singletonList(transform(occ.getName())));
contactParty.setContactPerson(contactPerson);
}
providerOrganization.setContactParty(Collections.singletonList(contactParty));
patientPerson.setBirthTime(transform(in.getBirthDateElement()));
if (in.hasGender()) {
switch(in.getGender()) {
case MALE:
patientPerson.setAdministrativeGenderCode(new CE("M", "Male", "2.16.840.1.113883.12.1"));
break;
case FEMALE:
patientPerson.setAdministrativeGenderCode(new CE("F", "Female", "2.16.840.1.113883.12.1"));
break;
case OTHER:
patientPerson.setAdministrativeGenderCode(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
break;
case UNKNOWN:
patientPerson.setAdministrativeGenderCode(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
break;
}
}
if (in.hasAddress())
patientPerson.setAddr(new ArrayList<AD>());
for (Address address : in.getAddress()) {
patientPerson.addAddr(transform(address));
}
for (ContactPoint contactPoint : in.getTelecom()) {
patientPerson.addTelecom(transform(contactPoint));
}
if (in.hasDeceasedBooleanType()) {
patientPerson.setDeceasedInd(new BL(in.getDeceasedBooleanType().getValue()));
}
if (in.hasDeceasedDateTimeType()) {
patientPerson.setDeceasedTime(transform(in.getDeceasedDateTimeType()));
}
if (in.hasMultipleBirthBooleanType()) {
patientPerson.setMultipleBirthInd(new BL(in.getMultipleBirthBooleanType().getValue()));
}
if (in.hasMultipleBirthIntegerType()) {
patientPerson.setMultipleBirthOrderNumber(new INT(in.getMultipleBirthIntegerType().getValue()));
}
if (in.hasMaritalStatus()) {
patientPerson.setMaritalStatusCode(transform(in.getMaritalStatus()));
}
if (in.hasCommunication()) {
for (PatientCommunicationComponent pcc : in.getCommunication()) {
PRPAMT201303UV02LanguageCommunication languageCommunication = new PRPAMT201303UV02LanguageCommunication();
languageCommunication.setLanguageCode(transform(pcc.getLanguage()));
if (pcc.hasPreferred())
languageCommunication.setPreferenceInd(new BL(pcc.getPreferred()));
patientPerson.addLanguageCommunication(languageCommunication);
}
}
MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian();
registrationEvent.setCustodian(custodian);
custodian.setTypeCode(ParticipationType.CST);
COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
custodian.setAssignedEntity(assignedEntity);
assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
List<II> custIds = new ArrayList<II>();
custIds.add(new II(getScheme(config.getCustodianOid()), null));
assignedEntity.setId(custIds);
// assignedEntity.setId(orgIds);
COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization();
assignedEntity.setAssignedOrganization(assignedOrganization);
assignedOrganization.setClassCode(EntityClassOrganization.ORG);
assignedOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
if (managingOrg.hasName()) {
ON onName = new ON();
onName.setMixed(Collections.singletonList(managingOrg.getName()));
assignedOrganization.setName(Collections.singletonList(onName));
}
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
HL7V3Transformer.marshallMessage(PRPAIN201304UV02Type.class, out, resultMsg);
String outArray = new String(out.toByteArray());
return outArray;
}
Aggregations