use of org.hl7.fhir.r4b.model.Identifier in project quality-measure-and-cohort-service by Alvearie.
the class ValueSetUtil method createArtifact.
public static ValueSetArtifact createArtifact(InputStream is, Map<String, String> customCodeSystem) throws IOException {
XSSFSheet informationSheet;
try (XSSFWorkbook wb = new XSSFWorkbook(is)) {
informationSheet = wb.getSheetAt(wb.getSheetIndex("Expansion List"));
} catch (IllegalArgumentException e) {
throw new RuntimeException("Spreadsheet is missing required sheet \"Expansion List\"", e);
}
ValueSet valueSet = new ValueSet();
boolean inCodesSection = false;
valueSet.setStatus(Enumerations.PublicationStatus.ACTIVE);
HashMap<CodeSystemKey, List<ValueSet.ConceptReferenceComponent>> codeSystemToCodes = new HashMap<>();
String url = "http://cts.nlm.nih.gov/fhir/ValueSet/";
String identifier = null;
for (Row currentRow : informationSheet) {
String code = currentRow.getCell(0) == null ? "" : currentRow.getCell(0).getStringCellValue();
if (!code.equals("") && currentRow.getCell(1) != null && !inCodesSection) {
String value;
switch(currentRow.getCell(1).getCellType()) {
case NUMERIC:
value = Double.toString(currentRow.getCell(1).getNumericCellValue());
break;
case STRING:
value = currentRow.getCell(1).getStringCellValue();
break;
default:
throw new RuntimeException("Cell type does not match either String or Numeric for key " + code);
}
switch(currentRow.getCell(0).getStringCellValue().toLowerCase()) {
case "value set name":
valueSet.setName(value);
valueSet.setTitle(value);
break;
case "id":
valueSet.setId(value);
identifier = value;
break;
case "oid":
if (valueSet.getId() == null) {
valueSet.setId(value);
identifier = value;
}
break;
case "url":
// fallthrough
url = value.endsWith("/") ? value : value + "/";
case "definition version":
valueSet.setVersion(value);
break;
case "code":
inCodesSection = true;
break;
default:
break;
}
} else if (inCodesSection) {
String display = currentRow.getCell(1).getStringCellValue();
String codeSystemEntry = currentRow.getCell(2).getStringCellValue();
String codeSystemVersion = currentRow.getCell(3).getStringCellValue();
String codeSystem;
if (codeSystemEntry.startsWith("http://") || codeSystemEntry.startsWith("https://")) {
codeSystem = codeSystemEntry;
} else if (customCodeSystem != null && customCodeSystem.get(codeSystemEntry) != null) {
codeSystem = customCodeSystem.get(codeSystemEntry);
} else {
codeSystem = CodeSystemLookup.getUrlFromName(codeSystemEntry);
}
if (codeSystem == null) {
throw new IllegalArgumentException("Unmatched Code System! " + codeSystemEntry + " not found!");
}
ValueSet.ConceptReferenceComponent concept = new ValueSet.ConceptReferenceComponent();
concept.setCode(code);
concept.setDisplay(display);
List<ValueSet.ConceptReferenceComponent> conceptsSoFar = codeSystemToCodes.computeIfAbsent(new CodeSystemKey(codeSystem, codeSystemVersion), x -> new ArrayList<>());
conceptsSoFar.add(concept);
}
}
if (identifier == null || identifier.equals("")) {
throw new RuntimeException("There must be an Identifier specified! Please populate the ID field");
}
valueSet.setUrl(url + identifier);
valueSet.setId(identifier);
ValueSet.ValueSetComposeComponent compose = new ValueSet.ValueSetComposeComponent();
for (Entry<CodeSystemKey, List<ConceptReferenceComponent>> singleInclude : codeSystemToCodes.entrySet()) {
ValueSet.ConceptSetComponent component = new ValueSet.ConceptSetComponent();
component.setSystem(singleInclude.getKey().getCodeSystem());
component.setVersion(singleInclude.getKey().getCodeSystemVersion());
component.setConcept(singleInclude.getValue());
compose.addInclude(component);
}
valueSet.setCompose(compose);
ValueSetArtifact artifact = new ValueSetArtifact();
artifact.setName(valueSet.getName());
artifact.setFhirResource(valueSet);
artifact.setUrl(valueSet.getUrl());
return artifact;
}
use of org.hl7.fhir.r4b.model.Identifier in project summary-care-record-api by NHSDigital.
the class AgentPersonSdsMapper method mapPractitionerRole.
private PractitionerRole mapPractitionerRole(Node agentPersonSds) {
var role = new PractitionerRole();
var roleProfileId = xmlUtils.getValueByXPath(agentPersonSds, ID_EXTENSION_XPATH);
role.setId(randomUUID());
role.addIdentifier(new Identifier().setSystem(SDS_ROLE_PROFILE_ID).setValue(roleProfileId));
return role;
}
use of org.hl7.fhir.r4b.model.Identifier in project summary-care-record-api by NHSDigital.
the class GpSummaryMapper method map.
@SneakyThrows
public List<Resource> map(Node document) {
var gpSummaryId = xmlUtils.getValueByXPath(document, GP_SUMMARY_ID_XPATH);
var gpSummaryCodeCode = xmlUtils.getValueByXPath(document, GP_SUMMARY_CODE_CODE_XPATH);
var gpSummaryCodeDisplayName = xmlUtils.getValueByXPath(document, GP_SUMMARY_CODE_DISPLAY_NAME_XPATH);
var gpSummaryStatusCode = xmlUtils.getValueByXPath(document, GP_SUMMARY_STATUS_CODE_XPATH);
var gpSummaryEffectiveTime = parseDate(xmlUtils.getValueByXPath(document, GP_SUMMARY_EFFECTIVE_TIME_XPATH), InstantType.class);
var authorTime = parseDate(xmlUtils.getValueByXPath(document, GP_SUMMARY_AUTHOR_TIME_XPATH), DateTimeType.class);
var replacementOfPriorMessageRefIdRoot = xmlUtils.getOptionalValueByXPath(document, REPLACEMENT_OF_PRIOR_MESSAGE_REF_ID_ROOT_XPATH);
var pertinentRootCreTypeCodeCode = xmlUtils.getValueByXPath(document, PERTINENT_ROOT_CRE_TYPE_CODE_CODE_XPATH);
var pertinentRootCreTypeCodeDisplayName = xmlUtils.getValueByXPath(document, PERTINENT_ROOT_CRE_TYPE_CODE_DISPLAY_NAME_XPATH);
var presentationTextValue = xmlUtils.detachOptionalNodeByXPath(document, PRESENTATION_TEXT_VALUE);
var eventId = xmlUtils.getValueByXPath(document, EVENT_ID_XPATH);
List<Resource> resources = new ArrayList<>();
var composition = new Composition();
composition.setId(eventId);
composition.setIdentifier(new Identifier().setValue(gpSummaryId).setSystem("https://tools.ietf.org/html/rfc4122"));
composition.setType(new CodeableConcept().addCoding(new Coding().setCode(gpSummaryCodeCode).setSystem(SNOMED_SYSTEM).setDisplay(gpSummaryCodeDisplayName)));
composition.setMeta(new Meta().setLastUpdatedElement(gpSummaryEffectiveTime));
composition.setStatus(mapCompositionStatus(gpSummaryStatusCode));
composition.setDateElement(authorTime);
replacementOfPriorMessageRefIdRoot.ifPresent(val -> composition.addRelatesTo(new Composition.CompositionRelatesToComponent().setTarget(new Identifier().setValue(val)).setCode(REPLACES)));
composition.addCategory(new CodeableConcept().addCoding(new Coding().setCode(pertinentRootCreTypeCodeCode).setSystem(SNOMED_SYSTEM).setDisplay(pertinentRootCreTypeCodeDisplayName)));
Map<String, List<String>> references = sectionReferences(document);
presentationTextValue.map(htmlParser::parse).map(Collection::stream).ifPresent(it -> it.forEach(section -> {
if (section.getTitle() != null && CODED_ENTRY_RESOURCE_MAP.keySet().contains(section.getTitle()) && references.containsKey(section.getTitle())) {
for (String codedEntryId : references.get(section.getTitle())) {
section.addEntry(new Reference(CODED_ENTRY_RESOURCE_MAP.get(section.getTitle()) + "/" + codedEntryId));
}
}
composition.addSection(section);
}));
resources.add(composition);
addAuthor(document, resources, composition);
return resources;
}
use of org.hl7.fhir.r4b.model.Identifier in project summary-care-record-api by NHSDigital.
the class GetScrService method buildPatientResource.
private Patient buildPatientResource(String nhsNumber) {
Patient patient = new Patient();
String patientResourceId = randomUUID();
patient.setId(patientResourceId);
patient.setIdentifier(asList(new Identifier().setSystem(NHS_ID_SYSTEM).setValue(nhsNumber)));
return patient;
}
use of org.hl7.fhir.r4b.model.Identifier in project summary-care-record-api by NHSDigital.
the class OrganisationSdsMapper method mapOrganizationSds.
public Organization mapOrganizationSds(Node organisationSds) {
var org = new Organization();
org.setId(randomUUID());
var orgIdentifier = new Identifier().setValue(xmlUtils.getValueByXPath(organisationSds, ORG_SDS_ID_XPATH));
var rootId = xmlUtils.getValueByXPath(organisationSds, ORG_SDS_ID_ROOT_XPATH);
if (HL7_ORG_OID.equals(rootId)) {
orgIdentifier.setSystem(ORG_SDS_SYSTEM);
}
org.addIdentifier(orgIdentifier);
xmlUtils.detachOptionalNodeByXPath(organisationSds, ORG_NAME_XPATH).ifPresent(nameNode -> org.setName(nameNode.getTextContent()));
return org;
}
Aggregations