Search in sources :

Example 71 with StringType

use of org.hl7.fhir.dstu2.model.StringType in project integration-adaptor-111 by nhsconnect.

the class QuestionnaireMapper method getItem.

private QuestionnaireItemComponent getItem(Question question, String caseId) {
    if (question != null) {
        List<QuestionnaireItemOptionComponent> questionnaireItemOptionComponentList = new ArrayList<>();
        QuestionnaireItemComponent item = new QuestionnaireItemComponent();
        item.setLinkId(caseId);
        item.setPrefix(getPrefix(question));
        item.setType(Questionnaire.QuestionnaireItemType.CHOICE);
        item.setRequired(true);
        item.setRepeats(false);
        if (question.getQuestionText() != null) {
            item.setText(question.getQuestionText());
        } else {
            item.setText(NOT_APPLICABLE);
        }
        if (question.getAnswers() != null) {
            if (question.getAnswers().sizeOfAnswerArray() > 0) {
                for (Answer answer : question.getAnswers().getAnswerArray()) {
                    QuestionnaireItemOptionComponent optionComponent = new QuestionnaireItemOptionComponent();
                    StringType answerStringType = new StringType();
                    answerStringType.setValueAsString(String.format("%s, Selected: %s", answer.getText(), answer.getSelected()));
                    optionComponent.setValue(answerStringType);
                    questionnaireItemOptionComponentList.add(optionComponent);
                }
            }
        }
        item.setOption(questionnaireItemOptionComponentList);
        return item;
    }
    return null;
}
Also used : Answer(org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase.PathwayDetails.PathwayTriageDetails.PathwayTriage.TriageLineDetails.TriageLine.Question.Answers.Answer) QuestionnaireItemComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent) StringType(org.hl7.fhir.dstu3.model.StringType) ArrayList(java.util.ArrayList) QuestionnaireItemOptionComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent)

Example 72 with StringType

use of org.hl7.fhir.dstu2.model.StringType in project integration-adaptor-111 by nhsconnect.

the class ObservationMapper method createObservation.

private Observation createObservation(Encounter encounter, List<String> sectionText) {
    Observation observation = new Observation();
    observation.setIdElement(resourceUtil.newRandomUuid());
    observation.setStatus(FINAL);
    Coding coding = new Coding().setCode(PRESENTING_COMPLAINT_CODE).setDisplay(PRESENTING_COMPLAINT_DISPLAY).setSystem(SNOMED_SYSTEM);
    observation.setCode(new CodeableConcept(coding));
    observation.setValue(new StringType(join(sectionText, '\n')));
    observation.setContext(resourceUtil.createReference(encounter));
    observation.setSubject(encounter.getSubject());
    return observation;
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) StringType(org.hl7.fhir.dstu3.model.StringType) Observation(org.hl7.fhir.dstu3.model.Observation) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 73 with StringType

use of org.hl7.fhir.dstu2.model.StringType in project integration-adaptor-111 by nhsconnect.

the class QuestionnaireResponseMapper method getItem.

private QuestionnaireResponseItemComponent getItem(Question question) {
    QuestionnaireResponseItemComponent item = new QuestionnaireResponseItemComponent();
    QuestionnaireResponseItemAnswerComponent answer = new QuestionnaireResponseItemAnswerComponent();
    StringType correctAnswerText = new StringType();
    if (StringUtils.isBlank(question.getQuestionId())) {
        item.setLinkId(NOT_APPLICABLE);
    } else {
        item.setLinkId(question.getQuestionId());
    }
    item.setText(question.getQuestionText());
    for (Answer singleAnswer : question.getAnswers().getAnswerArray()) {
        if (singleAnswer.getSelected() && !singleAnswer.getText().isBlank()) {
            correctAnswerText.setValueAsString(singleAnswer.getText());
        }
    }
    answer.setValue(correctAnswerText);
    item.addAnswer(answer);
    return item;
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) Answer(org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase.PathwayDetails.PathwayTriageDetails.PathwayTriage.TriageLineDetails.TriageLine.Question.Answers.Answer) StringType(org.hl7.fhir.dstu3.model.StringType) QuestionnaireResponseItemComponent(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent)

Example 74 with StringType

use of org.hl7.fhir.dstu2.model.StringType in project org.hl7.fhir.core by hapifhir.

the class IEEE11073Convertor method generateMDC.

public static CodeSystem generateMDC(String src, String dst, UcumService ucum) throws IOException, FHIRException {
    CSVReader csv = new CSVReader(new FileInputStream(src));
    csv.readHeaders();
    CodeSystem cs = new CodeSystem();
    Map<String, String> ucumIssues = new HashMap<String, String>();
    int errorCount = 0;
    cs.setId("MDC");
    cs.setUrl("urn:iso:std:iso:11073:10101");
    cs.setVersion("[todo]");
    cs.setName("11073:10101 codes for the FHIR community");
    cs.setStatus(PublicationStatus.ACTIVE);
    cs.setExperimental(false);
    cs.setDateElement(new DateTimeType());
    cs.setPublisher("HL7 (FHIR Project)");
    ContactDetail cd = cs.addContact();
    ContactPoint cp = cd.addTelecom();
    cp.setSystem(ContactPointSystem.URL);
    cp.setValue("http://ieee?");
    cs.setDescription("1073 Codes for the FHIR community (generated from the Rosetta data");
    Identifier i = new Identifier();
    cs.setIdentifier(i);
    i.setSystem("urn:ietf:rfc:3986");
    i.setValue("urn:oid:2.16.840.1.113883.6.24");
    cs.setCaseSensitive(false);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    cs.addProperty().setCode("ucum").setDescription("UCUM units associated with Concept").setType(PropertyType.STRING);
    cs.addProperty().setCode("unit").setDescription("MDC units associated with Concept").setType(PropertyType.STRING);
    cs.addProperty().setCode("refid").setDescription("MDC Reference Id for Concept").setType(PropertyType.CODE);
    Set<String> codes = new HashSet<String>();
    while (csv.line()) {
        if (csv.has("CF_CODE10")) {
            String code = csv.cell("CF_CODE10");
            if (codes.contains(code))
                System.out.println("Duplicate Code " + code);
            else {
                codes.add(code);
                ConceptDefinitionComponent c = cs.addConcept();
                c.setCode(code);
                c.setDisplay(csv.cell("Common Term"));
                c.setDefinition(csv.cell("Term Description"));
                String vd = csv.cell("Vendor_Description");
                if (!c.hasDefinition())
                    c.setDefinition(vd);
                if (!c.hasDisplay())
                    c.setDisplay(vd);
                String refid = csv.cell("REFID");
                c.addProperty().setCode("refid").setValue(new CodeType().setValue(refid));
                if (csv.has("Synonym"))
                    c.addDesignation().setValue(csv.cell("Synonym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("synonym"));
                if (csv.has("Acronym"))
                    c.addDesignation().setValue(csv.cell("Acronym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setDisplay("acronym"));
                if (csv.has("Systematic Name")) {
                    String sysName = csv.cell("Systematic Name");
                    if (!c.hasDefinition())
                        c.setDefinition(sysName);
                    c.addDesignation().setValue(sysName).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("structured-name"));
                }
                if (csv.has("UOM_MDC"))
                    c.addProperty().setCode("unit").setValue(new StringType().setValue(csv.cell("UOM_MDC")));
                if (csv.has("UOM_UCUM")) {
                    CommaSeparatedStringBuilder ul = new CommaSeparatedStringBuilder();
                    for (String u : csv.cell("UOM_UCUM").split(" ")) {
                        String msg = ucum.validate(u);
                        if (msg != null) {
                            errorCount++;
                            ucumIssues.put(u, msg);
                        } else
                            ul.append(u);
                    }
                    if (ul.length() > 0)
                        c.addProperty().setCode("ucum").setValue(new StringType().setValue(ul.toString()));
                }
            }
        }
    }
    csv.close();
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "codesystem-" + cs.getId() + ".xml")), cs);
    System.out.println(errorCount + "UCUM errors");
    for (String u : sorted(ucumIssues.keySet())) System.out.println("Invalid UCUM code: " + u + " because " + ucumIssues.get(u));
    return cs;
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) CSVReader(org.hl7.fhir.utilities.CSVReader) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) FileInputStream(java.io.FileInputStream) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) FileOutputStream(java.io.FileOutputStream)

Example 75 with StringType

use of org.hl7.fhir.dstu2.model.StringType in project org.hl7.fhir.core by hapifhir.

the class NUCCConvertor method processLine.

private void processLine(CodeSystem cs, String[] values) throws FHIRFormatError {
    ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
    cs.getConcept().add(cc);
    cc.setCode(values[0]);
    cc.setDisplay(values[4]);
    if (!Utilities.noString(values[1])) {
        cc.addProperty().setCode("grouping").setValue(new StringType(values[1]));
    }
    if (!Utilities.noString(values[2])) {
        cc.addProperty().setCode("classification").setValue(new StringType(values[2]));
    }
    if (!Utilities.noString(values[3])) {
        cc.addProperty().setCode("specialization").setValue(new StringType(values[3]));
    }
    if (values.length > 5 && !Utilities.noString(values[5]))
        cc.setDefinition(values[5]);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent) StringType(org.hl7.fhir.r4.model.StringType)

Aggregations

StringType (org.hl7.fhir.r4.model.StringType)158 ArrayList (java.util.ArrayList)77 Test (org.junit.jupiter.api.Test)77 StringType (org.hl7.fhir.dstu3.model.StringType)65 Parameters (org.hl7.fhir.r4.model.Parameters)62 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)62 StringType (org.hl7.fhir.r5.model.StringType)61 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)58 StringType (org.hl7.fhir.r4b.model.StringType)45 FHIRException (org.hl7.fhir.exceptions.FHIRException)43 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)42 HashMap (java.util.HashMap)28 StringType (org.hl7.fhir.dstu2.model.StringType)27 StringType (org.hl7.fhir.dstu2016may.model.StringType)26 Coding (org.hl7.fhir.r4.model.Coding)26 Extension (org.hl7.fhir.r4.model.Extension)25 Measure (org.hl7.fhir.r4.model.Measure)23 Test (org.junit.Test)23 Base (org.hl7.fhir.r5.model.Base)20 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19