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