Search in sources :

Example 46 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class CdaFhirUtilities method getPractitionersForType.

public static List<Practitioner> getPractitionersForType(R4FhirData data, V3ParticipationType type) {
    List<Practitioner> practs = new ArrayList<>();
    if (data != null && data.getEncounter() != null) {
        List<EncounterParticipantComponent> participants = data.getEncounter().getParticipant();
        if (participants != null && !participants.isEmpty()) {
            for (EncounterParticipantComponent part : participants) {
                if (part.getIndividual() != null && part.getIndividual().getReference() != null) {
                    logger.debug("Individual is present");
                    List<CodeableConcept> types = part.getType();
                    if (types != null && !types.isEmpty()) {
                        logger.debug("Codeable Concepts present for individuals");
                        for (CodeableConcept conc : types) {
                            logger.debug("Get Coding information for codeable concept");
                            List<Coding> typeCodes = conc.getCoding();
                            if (typeCodes != null && !typeCodes.isEmpty()) {
                                for (Coding cd : typeCodes) {
                                    if (cd.getSystem() != null && (cd.getSystem().contentEquals(CdaGeneratorConstants.FHIR_PARTICIPANT_TYPE) || cd.getSystem().contentEquals(CdaGeneratorConstants.FHIR_PARTICIPANT_TYPE_V3))) {
                                        logger.debug("Found Practitioner for Participation code system");
                                        if (cd.getCode() != null && cd.getCode().contentEquals(type.toString())) {
                                            logger.debug("Found Practitioner for Code and CodeSystem");
                                            logger.debug("part.getIndividual = {}", part.getIndividual().getDisplay());
                                            if (part.getIndividual().getReferenceElement() != null)
                                                logger.debug("part.getIndividual = {}", part.getIndividual().getReferenceElement());
                                            if (part.getIndividual().getReferenceElement() != null && part.getIndividual().getReferenceElement().getIdPart() != null) {
                                                Practitioner pr = data.getPractitionerById(part.getIndividual().getReferenceElement().getIdPart());
                                                if (pr != null) {
                                                    logger.info("Found Practitioner for Type {}", type);
                                                    practs.add(pr);
                                                }
                                            // Found Practitioenr
                                            } else // Valid Reference
                                            {
                                                logger.debug("Individual Ref Id is null");
                                            }
                                        } else // Found Type that we need
                                        {
                                            logger.debug("Did not find the code for type {}", type);
                                        }
                                    } else // Found participants that use standard code systems
                                    {
                                        logger.debug("Did not find participants using standard code system ");
                                    }
                                }
                            // For all Codings
                            }
                        // Codings present
                        }
                    // For all Codeable Concepts
                    }
                // Codeable Concept present
                }
            // PArticipant is an individual
            }
        // For all EncounteR ParticipantComponents
        }
    // Participants not empty
    }
    return practs;
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 47 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class CdaFhirUtilities method getXmlForType.

public static String getXmlForType(Type dt, String elName, Boolean valFlag) {
    String val = "";
    if (dt != null) {
        if (dt instanceof Coding) {
            Coding cd = (Coding) dt;
            List<Coding> cds = new ArrayList<>();
            cds.add(cd);
            if (!valFlag)
                val += getCodingXml(cds, elName, "");
            else
                val += getCodingXmlForValue(cds, elName);
        } else if (dt instanceof CodeableConcept) {
            CodeableConcept cd = (CodeableConcept) dt;
            List<Coding> cds = cd.getCoding();
            if (!valFlag)
                val += getCodingXml(cds, elName, "");
            else
                val += getCodingXmlForValue(cds, elName);
        } else if (dt instanceof Quantity) {
            Quantity qt = (Quantity) dt;
            val += getQuantityXml(qt, elName, valFlag);
        } else if (dt instanceof DateTimeType) {
            DateTimeType d = (DateTimeType) dt;
            val += CdaGeneratorUtils.getXmlForEffectiveTime(elName, d.getValue(), d.getTimeZone());
        } else if (dt instanceof Period) {
            Period pt = (Period) dt;
            val += getPeriodXml(pt, elName);
        } else if (dt instanceof Timing) {
            Timing t = (Timing) (dt);
            if (t.getRepeat() != null && t.getRepeat().getBounds() != null) {
                logger.debug("Found the bounds element for creating xml");
                String v = getXmlForType(t.getRepeat().getBounds(), elName, valFlag);
                val += v;
            }
        } else if (dt instanceof CodeType) {
            CodeType cd = (CodeType) dt;
            if (!valFlag)
                val += CdaGeneratorUtils.getXmlForCD(elName, cd.getCode());
            else
                val += CdaGeneratorUtils.getXmlForValueString(cd.getCode());
        } else if (dt instanceof StringType) {
            StringType st = (StringType) dt;
            if (!valFlag)
                val += CdaGeneratorUtils.getXmlForText(elName, st.getValue());
            else
                val += CdaGeneratorUtils.getXmlForValueString(st.getValue());
        }
        logger.debug("Printing the class name {}", dt.getClass());
        return val;
    }
    if (!valFlag)
        val += CdaGeneratorUtils.getNFXMLForElement(elName, CdaGeneratorConstants.NF_NI);
    else
        val += CdaGeneratorUtils.getNFXmlForValueString(CdaGeneratorConstants.NF_NI);
    return val;
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Coding(org.hl7.fhir.r4.model.Coding) StringType(org.hl7.fhir.r4.model.StringType) ArrayList(java.util.ArrayList) Quantity(org.hl7.fhir.r4.model.Quantity) Period(org.hl7.fhir.r4.model.Period) CodeType(org.hl7.fhir.r4.model.CodeType) List(java.util.List) ArrayList(java.util.ArrayList) Timing(org.hl7.fhir.r4.model.Timing) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 48 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class FhirGeneratorUtils method getCodeableConcept.

public static CodeableConcept getCodeableConcept(String system, String code, String display) {
    Coding cd = getCoding(system, code, display);
    CodeableConcept cc = null;
    if (cd != null) {
        cc = new CodeableConcept();
        cc.addCoding(cd);
        if (!StringUtils.isEmpty(display))
            cc.setText(display);
    }
    return cc;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 49 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class PlanDefinitionProcessor method processConditions.

private void processConditions(List<PlanDefinitionActionConditionComponent> condlist, AbstractAction act) {
    if (condlist != null && !condlist.isEmpty()) {
        for (PlanDefinitionActionConditionComponent cond : condlist) {
            if (cond.hasKind() && cond.hasExpression()) {
                CQLExpressionCondition cd = new CQLExpressionCondition();
                cd.setConditionType(cond.getKind());
                cd.setExpression(cond.getExpression().getExpression());
                act.addCondition(cd);
            }
        }
    }
}
Also used : CQLExpressionCondition(com.drajer.eca.model.CQLExpressionCondition) PlanDefinitionActionConditionComponent(org.hl7.fhir.r4.model.PlanDefinition.PlanDefinitionActionConditionComponent)

Example 50 with CD

use of org.hl7.v3.CD in project MobileAccessGateway by i4mi.

the class Iti83RequestConverter method iti83ToIti45Converter.

public String iti83ToIti45Converter(Parameters parameters) throws JAXBException {
    List<Type> targetSystemList = (List<Type>) parameters.getParameters("targetSystem");
    Identifier sourceIdentifier = (Identifier) parameters.getParameter("sourceIdentifier");
    PRPAIN201309UV02Type resultMsg = new PRPAIN201309UV02Type();
    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_IN201309UV02"));
    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)));
    PRPAIN201309UV02QUQIMT021001UV01ControlActProcess controlActProcess = new PRPAIN201309UV02QUQIMT021001UV01ControlActProcess();
    resultMsg.setControlActProcess(controlActProcess);
    controlActProcess.setClassCode(ActClassControlAct.CACT);
    controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
    controlActProcess.setCode(new CD("PRPA_TE201309UV02", "2.16.840.1.113883.1.18", null));
    PRPAMT201307UV02QueryByParameter queryByParameter = new PRPAMT201307UV02QueryByParameter();
    controlActProcess.setQueryByParameter(queryByParameter);
    queryByParameter.setQueryId(new II(config.getPixQueryOid(), uniqueId()));
    queryByParameter.setStatusCode(new CS("new", null, null));
    queryByParameter.setResponsePriorityCode(new CS("I", null, null));
    PRPAMT201307UV02ParameterList parameterList = new PRPAMT201307UV02ParameterList();
    queryByParameter.setParameterList(parameterList);
    PRPAMT201307UV02PatientIdentifier patientIdentifier = new PRPAMT201307UV02PatientIdentifier();
    parameterList.addPatientIdentifier(patientIdentifier);
    String system = getScheme(sourceIdentifier.getSystem());
    patientIdentifier.setValue(Collections.singletonList(new II(system, sourceIdentifier.getValue())));
    patientIdentifier.setSemanticsText(ST("Patient.id"));
    if (targetSystemList != null && (targetSystemList.size() > 0)) {
        for (Type targetSystemType : targetSystemList) {
            UriType targetSystem = (UriType) targetSystemType;
            String sourceSystem = getScheme(targetSystem.getValue());
            PRPAMT201307UV02DataSource dataSource = new PRPAMT201307UV02DataSource();
            parameterList.addDataSource(dataSource);
            dataSource.setValue(Collections.singletonList(new II(sourceSystem, null, null)));
            dataSource.setSemanticsText(ST("DataSource.id"));
        }
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    log.debug("PRE CONVERT");
    HL7V3Transformer.marshallMessage(PRPAIN201309UV02Type.class, out, resultMsg);
    log.debug("POST CONVERT");
    String outArray = new String(out.toByteArray());
    log.debug(outArray);
    return outArray;
}
Also used : II(net.ihe.gazelle.hl7v3.datatypes.II) CD(net.ihe.gazelle.hl7v3.datatypes.CD) PRPAMT201307UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PRPAIN201309UV02Type(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02Type) MCCIMT000100UV01Sender(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender) UriType(org.hl7.fhir.r4.model.UriType) CS(net.ihe.gazelle.hl7v3.datatypes.CS) Type(org.hl7.fhir.r4.model.Type) CommunicationFunctionType(net.ihe.gazelle.hl7v3.voc.CommunicationFunctionType) PRPAIN201309UV02Type(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02Type) UriType(org.hl7.fhir.r4.model.UriType) Identifier(org.hl7.fhir.r4.model.Identifier) PRPAMT201307UV02PatientIdentifier(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier) PRPAMT201307UV02DataSource(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource) PRPAIN201309UV02QUQIMT021001UV01ControlActProcess(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02QUQIMT021001UV01ControlActProcess) PRPAMT201307UV02QueryByParameter(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter) PRPAMT201307UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList) List(java.util.List) MCCIMT000100UV01Receiver(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver) PRPAMT201307UV02PatientIdentifier(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier) MCCIMT000100UV01Device(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device) TS(net.ihe.gazelle.hl7v3.datatypes.TS)

Aggregations

ArrayList (java.util.ArrayList)24 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 Coding (org.hl7.fhir.r4.model.Coding)10 ValueSet (org.hl7.fhir.r5.model.ValueSet)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)9 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 CD (net.ihe.gazelle.hl7v3.datatypes.CD)7 CS (net.ihe.gazelle.hl7v3.datatypes.CS)7 II (net.ihe.gazelle.hl7v3.datatypes.II)7 TS (net.ihe.gazelle.hl7v3.datatypes.TS)7 MCCIMT000100UV01Device (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device)7 MCCIMT000100UV01Receiver (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver)7 MCCIMT000100UV01Sender (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender)7 Identifier (org.hl7.fhir.r4.model.Identifier)7 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)7 IOException (java.io.IOException)6 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)6 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)5