Search in sources :

Example 1 with MCCIMT000300UV01AcknowledgementDetail

use of net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01AcknowledgementDetail in project MobileAccessGateway by i4mi.

the class Iti78ResponseConverter method translateToFhir.

public List<Patient> translateToFhir(byte[] input, Map<String, Object> parameters) {
    try {
        // FIX for xmlns:xmlns
        String content = new String(input);
        content = content.replace("xmlns:xmlns", "xmlns:xxxxx");
        List<Patient> response = new ArrayList<Patient>();
        PRPAIN201306UV02Type msg = HL7V3Transformer.unmarshallMessage(PRPAIN201306UV02Type.class, new ByteArrayInputStream(content.getBytes()));
        PRPAIN201306UV02MFMIMT700711UV01ControlActProcess controlAct = msg.getControlActProcess();
        List<MCCIMT000300UV01Acknowledgement> acks = msg.getAcknowledgement();
        String errtext = "";
        for (MCCIMT000300UV01Acknowledgement ack : acks) {
            for (MCCIMT000300UV01AcknowledgementDetail ackDetail : ack.getAcknowledgementDetail()) {
                if (ackDetail.getText() != null)
                    errtext += toText(ackDetail.getText());
            }
        }
        // OK NF AE
        String queryResponseCode = controlAct.getQueryAck().getQueryResponseCode().getCode();
        if ("NF".equals(queryResponseCode)) {
            throw new ResourceNotFoundException("sourceIdentifier Patient Identifier not found", error(IssueType.NOTFOUND, errtext.length() > 0 ? errtext : "sourceIdentifier Patient Identifier not found"));
        }
        if ("AE".equals(queryResponseCode)) {
            throw new InvalidRequestException("sourceIdentifier Assigning Authority not found", error(IssueType.INVALID, errtext.length() > 0 ? errtext : "sourceIdentifier Assigning Authority not found"));
        }
        List<PRPAIN201306UV02MFMIMT700711UV01Subject1> subjects = controlAct.getSubject();
        for (PRPAIN201306UV02MFMIMT700711UV01Subject1 subject : subjects) {
            PRPAIN201306UV02MFMIMT700711UV01RegistrationEvent registrationEvent = subject.getRegistrationEvent();
            PRPAIN201306UV02MFMIMT700711UV01Subject2 subject1 = registrationEvent.getSubject1();
            PRPAMT201310UV02Patient patient = subject1.getPatient();
            PRPAMT201310UV02Person patientPerson = patient.getPatientPerson();
            if (patient.getId().isEmpty())
                continue;
            Patient result = new Patient();
            boolean idadded = false;
            for (II patientId : patient.getId()) {
                result.addIdentifier().setSystem(getSystem(patientId.getRoot())).setValue(patientId.getExtension());
                if (!idadded) {
                    result.setId(patientRefCreator.createPatientId(patientId.getRoot(), patientId.getExtension()));
                    idadded = true;
                }
            }
            for (PRPAMT201310UV02OtherIDs otherIds : patient.getPatientPerson().getAsOtherIDs()) {
                for (II patientId : otherIds.getId()) {
                    result.addIdentifier().setSystem(getSystem(patientId.getRoot())).setValue(patientId.getExtension());
                }
            }
            CS statusCode = patient.getStatusCode();
            if (statusCode != null && "active".equals(statusCode.getCode()))
                result.setActive(true);
            for (PN name : patientPerson.getName()) {
                HumanName humanName = new HumanName();
                for (EnFamily family : name.getFamily()) {
                    if ("BR".equals(family.getQualifier())) {
                        humanName.setUse(NameUse.MAIDEN);
                    }
                    humanName.setFamily(val(family));
                }
                for (EnGiven given : name.getGiven()) {
                    withQualifier(given, humanName.addGivenElement());
                }
                for (EnPrefix prefix : name.getPrefix()) {
                    withQualifier(prefix, humanName.addPrefixElement());
                }
                for (EnSuffix suffix : name.getSuffix()) {
                    withQualifier(suffix, humanName.addSuffixElement());
                }
                if (name.getValidTime() != null)
                    humanName.setPeriod(transform(name.getValidTime()));
                result.addName(humanName);
            }
            CE gender = patientPerson.getAdministrativeGenderCode();
            if (gender != null) {
                switch(gender.getCode()) {
                    case "M":
                        result.setGender(AdministrativeGender.MALE);
                        break;
                    case "F":
                        result.setGender(AdministrativeGender.FEMALE);
                        break;
                    case "A":
                        result.setGender(AdministrativeGender.OTHER);
                        break;
                    case "U":
                        result.setGender(AdministrativeGender.UNKNOWN);
                        break;
                }
            }
            TS birthTime = patientPerson.getBirthTime();
            if (birthTime != null) {
                result.setBirthDateElement(transform(birthTime));
            }
            for (AD ad : patientPerson.getAddr()) {
                result.addAddress(transform(ad));
            }
            for (TEL tel : patientPerson.getTelecom()) {
                result.addTelecom(transform(tel));
            }
            for (PRPAMT201310UV02LanguageCommunication lang : patientPerson.getLanguageCommunication()) {
                CE langCode = lang.getLanguageCode();
                PatientCommunicationComponent pcc = new PatientCommunicationComponent();
                pcc.setLanguage(transform(langCode));
                BL preferred = lang.getPreferenceInd();
                if (preferred != null && preferred.getValue().booleanValue())
                    pcc.setPreferred(true);
                result.addCommunication(pcc);
            }
            TS deceasedTime = patientPerson.getDeceasedTime();
            if (deceasedTime != null)
                result.setDeceased(transform(deceasedTime));
            else {
                BL deceased = patientPerson.getDeceasedInd();
                if (deceased != null)
                    result.setDeceased(new BooleanType(deceased.getValue().booleanValue()));
            }
            INT multiBirthOrder = patientPerson.getMultipleBirthOrderNumber();
            if (multiBirthOrder != null) {
                result.setMultipleBirth(new IntegerType(multiBirthOrder.getValue()));
            } else {
                BL multipleBirth = patientPerson.getMultipleBirthInd();
                if (multipleBirth != null)
                    result.setMultipleBirth(new BooleanType(multipleBirth.getValue().booleanValue()));
            }
            CE maritalStatus = patientPerson.getMaritalStatusCode();
            result.setMaritalStatus(transform(maritalStatus));
            for (PRPAMT201310UV02PersonalRelationship relationShip : patientPerson.getPersonalRelationship()) {
                CE code = relationShip.getCode();
                if (code != null && "MTH".equals(code.getCode()) && "2.16.840.1.113883.12.63".equals(code.getCodeSystem())) {
                    COCTMT030007UVPerson holder = relationShip.getRelationshipHolder1();
                    if (holder != null && !holder.getName().isEmpty()) {
                        EN name = holder.getName().get(0);
                        if (!name.getFamily().isEmpty()) {
                            String familyName = val(name.getFamily());
                            result.addExtension("http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", new StringType(familyName));
                        }
                    }
                }
            }
            response.add(result);
        }
        return response;
    } catch (JAXBException e) {
        e.printStackTrace();
        throw new InvalidRequestException("failed parsing response");
    }
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) ArrayList(java.util.ArrayList) PRPAIN201306UV02MFMIMT700711UV01Subject2(net.ihe.gazelle.hl7v3.prpain201306UV02.PRPAIN201306UV02MFMIMT700711UV01Subject2) PRPAIN201306UV02MFMIMT700711UV01Subject1(net.ihe.gazelle.hl7v3.prpain201306UV02.PRPAIN201306UV02MFMIMT700711UV01Subject1) BL(net.ihe.gazelle.hl7v3.datatypes.BL) MCCIMT000300UV01Acknowledgement(net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01Acknowledgement) PRPAMT201310UV02Patient(net.ihe.gazelle.hl7v3.prpamt201310UV02.PRPAMT201310UV02Patient) INT(net.ihe.gazelle.hl7v3.datatypes.INT) HumanName(org.hl7.fhir.r4.model.HumanName) COCTMT030007UVPerson(net.ihe.gazelle.hl7v3.coctmt030007UV.COCTMT030007UVPerson) PatientCommunicationComponent(org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent) PRPAMT201310UV02OtherIDs(net.ihe.gazelle.hl7v3.prpamt201310UV02.PRPAMT201310UV02OtherIDs) EnFamily(net.ihe.gazelle.hl7v3.datatypes.EnFamily) PRPAMT201310UV02Person(net.ihe.gazelle.hl7v3.prpamt201310UV02.PRPAMT201310UV02Person) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) EnSuffix(net.ihe.gazelle.hl7v3.datatypes.EnSuffix) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) PRPAIN201306UV02MFMIMT700711UV01RegistrationEvent(net.ihe.gazelle.hl7v3.prpain201306UV02.PRPAIN201306UV02MFMIMT700711UV01RegistrationEvent) PRPAIN201306UV02Type(net.ihe.gazelle.hl7v3.prpain201306UV02.PRPAIN201306UV02Type) II(net.ihe.gazelle.hl7v3.datatypes.II) PRPAIN201306UV02MFMIMT700711UV01ControlActProcess(net.ihe.gazelle.hl7v3.prpain201306UV02.PRPAIN201306UV02MFMIMT700711UV01ControlActProcess) CE(net.ihe.gazelle.hl7v3.datatypes.CE) EnPrefix(net.ihe.gazelle.hl7v3.datatypes.EnPrefix) AD(net.ihe.gazelle.hl7v3.datatypes.AD) JAXBException(javax.xml.bind.JAXBException) BooleanType(org.hl7.fhir.r4.model.BooleanType) Patient(org.hl7.fhir.r4.model.Patient) PRPAMT201310UV02Patient(net.ihe.gazelle.hl7v3.prpamt201310UV02.PRPAMT201310UV02Patient) EnGiven(net.ihe.gazelle.hl7v3.datatypes.EnGiven) EN(net.ihe.gazelle.hl7v3.datatypes.EN) CS(net.ihe.gazelle.hl7v3.datatypes.CS) IntegerType(org.hl7.fhir.r4.model.IntegerType) PRPAMT201310UV02PersonalRelationship(net.ihe.gazelle.hl7v3.prpamt201310UV02.PRPAMT201310UV02PersonalRelationship) ByteArrayInputStream(java.io.ByteArrayInputStream) TEL(net.ihe.gazelle.hl7v3.datatypes.TEL) MCCIMT000300UV01AcknowledgementDetail(net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01AcknowledgementDetail) PRPAMT201310UV02LanguageCommunication(net.ihe.gazelle.hl7v3.prpamt201310UV02.PRPAMT201310UV02LanguageCommunication) PN(net.ihe.gazelle.hl7v3.datatypes.PN) IVXBTS(net.ihe.gazelle.hl7v3.datatypes.IVXBTS) IVLTS(net.ihe.gazelle.hl7v3.datatypes.IVLTS) TS(net.ihe.gazelle.hl7v3.datatypes.TS)

Example 2 with MCCIMT000300UV01AcknowledgementDetail

use of net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01AcknowledgementDetail in project MobileAccessGateway by i4mi.

the class Iti83ResponseConverter method translateToFhir.

public Parameters translateToFhir(byte[] input, Map<String, Object> parameters) {
    try {
        // FIX for xmlns:xmlns
        String content = new String(input);
        content = content.replace("xmlns:xmlns", "xmlns:xxxxx");
        PRPAIN201310UV02Type msg = HL7V3Transformer.unmarshallMessage(PRPAIN201310UV02Type.class, new ByteArrayInputStream(content.getBytes()));
        Parameters query = (Parameters) parameters.get(Utils.KEPT_BODY);
        List<Type> targetSystemList = (List<Type>) query.getParameters("targetSystem");
        Parameters response = new Parameters();
        PRPAIN201310UV02MFMIMT700711UV01ControlActProcess controlAct = msg.getControlActProcess();
        List<MCCIMT000300UV01Acknowledgement> acks = msg.getAcknowledgement();
        String errtext = "";
        for (MCCIMT000300UV01Acknowledgement ack : acks) {
            for (MCCIMT000300UV01AcknowledgementDetail ackDetail : ack.getAcknowledgementDetail()) {
                if (ackDetail.getText() != null)
                    errtext += toText(ackDetail.getText());
            }
        }
        // OK NF AE
        String queryResponseCode = controlAct.getQueryAck().getQueryResponseCode().getCode();
        if ("NF".equals(queryResponseCode)) {
            throw new ResourceNotFoundException("sourceIdentifier Patient Identifier not found", error(IssueType.NOTFOUND, errtext.length() > 0 ? errtext : "sourceIdentifier Patient Identifier not found"));
        }
        if ("AE".equals(queryResponseCode)) {
            throw new InvalidRequestException("sourceIdentifier Assigning Authority not found", error(IssueType.INVALID, errtext.length() > 0 ? errtext : "sourceIdentifier Assigning Authority not found"));
        }
        Set<String> acceptedTargetSystem = new HashSet<String>();
        Set<String> noDuplicates = new HashSet<String>();
        if (targetSystemList != null) {
            for (Type targetSystemType : targetSystemList) {
                UriType targetSystem = (UriType) targetSystemType;
                acceptedTargetSystem.add(targetSystem.getValue());
            }
        }
        List<PRPAIN201310UV02MFMIMT700711UV01Subject1> subjects = controlAct.getSubject();
        for (PRPAIN201310UV02MFMIMT700711UV01Subject1 subject : subjects) {
            boolean targetIdAdded = false;
            List<II> ids = new ArrayList<II>();
            ids.addAll(subject.getRegistrationEvent().getSubject1().getPatient().getId());
            for (var otherId : subject.getRegistrationEvent().getSubject1().getPatient().getPatientPerson().getAsOtherIDs()) {
                ids.addAll(otherId.getId());
            }
            for (II ii : ids) {
                String root = ii.getRoot();
                String extension = ii.getExtension();
                if (!noDuplicates.contains(root) && (acceptedTargetSystem.isEmpty() || acceptedTargetSystem.contains("urn:oid:" + root))) {
                    response.addParameter().setName("targetIdentifier").setValue((new Identifier()).setSystem("urn:oid:" + root).setValue(extension));
                    noDuplicates.add(root);
                }
                if (!targetIdAdded && root.equals(config.getOidMpiPid())) {
                    response.addParameter().setName("targetId").setValue(patientRefCreator.createPatientReference(root, extension));
                    targetIdAdded = true;
                }
            }
        }
        return response;
    } catch (JAXBException e) {
        e.printStackTrace();
        throw new InvalidRequestException("failed parsing response");
    }
}
Also used : PRPAIN201310UV02Type(net.ihe.gazelle.hl7v3.prpain201310UV02.PRPAIN201310UV02Type) PRPAIN201310UV02MFMIMT700711UV01Subject1(net.ihe.gazelle.hl7v3.prpain201310UV02.PRPAIN201310UV02MFMIMT700711UV01Subject1) ArrayList(java.util.ArrayList) MCCIMT000300UV01Acknowledgement(net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01Acknowledgement) UriType(org.hl7.fhir.r4.model.UriType) Identifier(org.hl7.fhir.r4.model.Identifier) ArrayList(java.util.ArrayList) List(java.util.List) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) HashSet(java.util.HashSet) II(net.ihe.gazelle.hl7v3.datatypes.II) Parameters(org.hl7.fhir.r4.model.Parameters) JAXBException(javax.xml.bind.JAXBException) PRPAIN201310UV02MFMIMT700711UV01ControlActProcess(net.ihe.gazelle.hl7v3.prpain201310UV02.PRPAIN201310UV02MFMIMT700711UV01ControlActProcess) Type(org.hl7.fhir.r4.model.Type) IssueType(org.hl7.fhir.r4.model.OperationOutcome.IssueType) UriType(org.hl7.fhir.r4.model.UriType) PRPAIN201310UV02Type(net.ihe.gazelle.hl7v3.prpain201310UV02.PRPAIN201310UV02Type) ByteArrayInputStream(java.io.ByteArrayInputStream) MCCIMT000300UV01AcknowledgementDetail(net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01AcknowledgementDetail)

Example 3 with MCCIMT000300UV01AcknowledgementDetail

use of net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01AcknowledgementDetail in project ipf by oehf.

the class PixV3QueryResponseTransformerTest method getSampleResponse.

public static PixV3QueryResponse getSampleResponse() {
    final PixV3QueryResponse response = PixV3QueryResponse.fromQuery(getSampleQuery());
    response.setDataFound();
    response.setTargetMessageId(new II("m1", "1.3.5"));
    response.setMessageId(new II("m2", "1.3.5"));
    response.getPatientIds().addAll(List.of(new II("9810", "2.16.756.5.30.1.127")));
    response.setCustodianOid("1.4.2");
    response.setProviderOrganization(new COCTMT150003UV03Organization());
    response.getProviderOrganization().getName().add(new ON());
    response.getProviderOrganization().getName().get(0).mixed = List.of("Provider Organization");
    response.setPersonName(new PN());
    response.getPersonName().mixed = List.of("Person Name");
    response.getPersonIds().add(new II("76133761", "1.3.6.1.4.1.12559.11.25.1.19"));
    response.getAsOtherIDs().add(new PRPAMT201304UV02OtherIDs());
    response.getAsOtherIDs().get(0).setId(List.of(new II("1.2.840.114350.1.13", "38273N237")));
    final MCCIMT000300UV01AcknowledgementDetail ad = new MCCIMT000300UV01AcknowledgementDetail();
    ad.setCode(new CE("204", null, null));
    ad.getLocation().add(new ST());
    ad.getLocation().get(0).mixed = List.of("/hl7:PRPA_IN201309UV02/hl7:controlActProcess");
    ad.setText(new ED());
    ad.getText().mixed = List.of("Requested record not found");
    response.getAcknowledgementDetails().add(ad);
    return response;
}
Also used : COCTMT150003UV03Organization(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Organization) PRPAMT201304UV02OtherIDs(net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02OtherIDs) PixV3QueryResponse(org.openehealth.ipf.commons.ihe.hl7v3.core.responses.PixV3QueryResponse) MCCIMT000300UV01AcknowledgementDetail(net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01AcknowledgementDetail)

Aggregations

MCCIMT000300UV01AcknowledgementDetail (net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01AcknowledgementDetail)3 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)2 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ArrayList (java.util.ArrayList)2 JAXBException (javax.xml.bind.JAXBException)2 II (net.ihe.gazelle.hl7v3.datatypes.II)2 MCCIMT000300UV01Acknowledgement (net.ihe.gazelle.hl7v3.mccimt000300UV01.MCCIMT000300UV01Acknowledgement)2 HashSet (java.util.HashSet)1 List (java.util.List)1 COCTMT030007UVPerson (net.ihe.gazelle.hl7v3.coctmt030007UV.COCTMT030007UVPerson)1 COCTMT150003UV03Organization (net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Organization)1 AD (net.ihe.gazelle.hl7v3.datatypes.AD)1 BL (net.ihe.gazelle.hl7v3.datatypes.BL)1 CE (net.ihe.gazelle.hl7v3.datatypes.CE)1 CS (net.ihe.gazelle.hl7v3.datatypes.CS)1 EN (net.ihe.gazelle.hl7v3.datatypes.EN)1 EnFamily (net.ihe.gazelle.hl7v3.datatypes.EnFamily)1 EnGiven (net.ihe.gazelle.hl7v3.datatypes.EnGiven)1 EnPrefix (net.ihe.gazelle.hl7v3.datatypes.EnPrefix)1