Search in sources :

Example 6 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project gpconnect-demonstrator by nhsconnect.

the class MedicationRequestResourceProvider method getMedicationRequestFromDetail.

private MedicationRequest getMedicationRequestFromDetail(MedicationRequestDetail requestDetail) {
    MedicationRequest medicationRequest = new MedicationRequest();
    medicationRequest.setId(requestDetail.getId().toString());
    List<Identifier> identifiers = new ArrayList<>();
    Identifier identifier = new Identifier().setSystem("https://fhir.nhs.uk/Id/cross-care-setting-identifier").setValue(requestDetail.getGuid());
    identifiers.add(identifier);
    medicationRequest.setIdentifier(identifiers);
    medicationRequest.setMeta(new Meta().addProfile(SystemURL.SD_GPC_MEDICATION_REQUEST));
    setBasedOnReferences(medicationRequest, requestDetail);
    if (requestDetail.getPrescriptionTypeCode().contains("repeat")) {
        medicationRequest.setGroupIdentifier(new Identifier().setValue(requestDetail.getGroupIdentifier()));
    }
    try {
        medicationRequest.setStatus(MedicationRequestStatus.fromCode(requestDetail.getStatusCode()));
    } catch (FHIRException e) {
        throw new UnprocessableEntityException(e.getMessage());
    }
    try {
        medicationRequest.setIntent(MedicationRequestIntent.fromCode(requestDetail.getIntentCode()));
    } catch (FHIRException e) {
        throw new UnprocessableEntityException(e.getMessage());
    }
    if (requestDetail.getMedicationId() != null) {
        medicationRequest.setMedication(new Reference(new IdType("Medication", requestDetail.getMedicationId())));
    }
    if (requestDetail.getPatientId() != null) {
        medicationRequest.setSubject(new Reference(new IdType("Patient", requestDetail.getPatientId())));
    }
    if (requestDetail.getAuthorisingPractitionerId() != null) {
        medicationRequest.setRecorder(new Reference(new IdType("Practitioner", requestDetail.getAuthorisingPractitionerId())));
    }
    if (requestDetail.getPriorMedicationRequestId() != null) {
        medicationRequest.setPriorPrescription(new Reference(new IdType("MedicationRequest", requestDetail.getPriorMedicationRequestId())));
    }
    medicationRequest.setAuthoredOn(requestDetail.getAuthoredOn());
    medicationRequest.setDispenseRequest(getDispenseRequestComponent(requestDetail));
    // medicationRequest.setRequester(getRequesterComponent(requestDetail)); //TODO - spec needs to clarify whether this should be populated or not
    setReasonCodes(medicationRequest, requestDetail);
    setNotes(medicationRequest, requestDetail);
    if (medicationRequest.getIntent() != MedicationRequestIntent.ORDER) {
        setRepeatInformation(medicationRequest, requestDetail);
    }
    setPrescriptionType(medicationRequest, requestDetail);
    setStatusReason(medicationRequest, requestDetail);
    String dosageInstructionText = requestDetail.getDosageText();
    medicationRequest.addDosageInstruction(new Dosage().setText(dosageInstructionText == null || dosageInstructionText.trim().isEmpty() ? NO_INFORMATION_AVAILABLE : dosageInstructionText).setPatientInstruction(requestDetail.getDosageInstructions()));
    return medicationRequest;
}
Also used : UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) ArrayList(java.util.ArrayList) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 7 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project gpconnect-demonstrator by nhsconnect.

the class OrganizationResourceProvider method convertOrganizatonDetailsListToOrganizationList.

private List<Organization> convertOrganizatonDetailsListToOrganizationList(List<OrganizationDetails> organizationDetails) {
    Map<Long, Organization> map = new HashMap<>();
    for (OrganizationDetails organizationDetail : organizationDetails) {
        // Changed key to be logical id rather than ods code since can have > 1 org per ods code
        // for 1.2.2
        Long mapKey = organizationDetail.getId();
        if (map.containsKey(mapKey)) {
            continue;
        }
        Identifier identifier = new Identifier().setSystem(SystemURL.ID_ODS_ORGANIZATION_CODE).setValue(organizationDetail.getOrgCode());
        Organization organization = new Organization().setName(organizationDetail.getOrgName()).addIdentifier(identifier);
        String resourceId = String.valueOf(organizationDetail.getId());
        String versionId = String.valueOf(organizationDetail.getLastUpdated().getTime());
        String resourceType = organization.getResourceType().toString();
        IdType id = new IdType(resourceType, resourceId, versionId);
        organization.setId(id);
        organization.getMeta().setVersionId(versionId);
        organization.getMeta().setLastUpdated(organizationDetail.getLastUpdated());
        organization.getMeta().addProfile(SystemURL.SD_GPC_ORGANIZATION);
        organization = addAdditionalProperties(organization);
        map.put(mapKey, organization);
    }
    return new ArrayList<>(map.values());
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) Identifier(org.hl7.fhir.dstu3.model.Identifier) HashMap(java.util.HashMap) OrganizationDetails(uk.gov.hscic.model.organization.OrganizationDetails) ArrayList(java.util.ArrayList) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 8 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project bunsen by cerner.

the class TestData method newObservation.

/**
 * Returns a FHIR Observation for testing purposes.
 */
public static Observation newObservation() {
    // Observation based on https://www.hl7.org/FHIR/observation-example-bloodpressure.json.html
    Observation observation = new Observation();
    observation.setId("blood-pressure");
    Identifier identifier = observation.addIdentifier();
    identifier.setSystem("urn:ietf:rfc:3986");
    identifier.setValue("urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281");
    observation.setStatus(Observation.ObservationStatus.FINAL);
    Quantity quantity = new Quantity();
    quantity.setValue(new java.math.BigDecimal("123.45"));
    quantity.setUnit("mm[Hg]");
    observation.setValue(quantity);
    return observation;
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) Observation(org.hl7.fhir.dstu3.model.Observation) Quantity(org.hl7.fhir.dstu3.model.Quantity)

Example 9 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method addCareTeamPractitioner.

/**
 * Ensures that the specified {@link ExplanationOfBenefit} has the specified {@link
 * CareTeamComponent}, and links the specified {@link ItemComponent} to that {@link
 * CareTeamComponent} (via {@link ItemComponent#addCareTeamLinkId(int)}).
 *
 * @param eob the {@link ExplanationOfBenefit} that the {@link CareTeamComponent} should be part
 *     of
 * @param eobItem the {@link ItemComponent} that should be linked to the {@link CareTeamComponent}
 * @param practitionerIdSystem the {@link Identifier#getSystem()} of the practitioner to reference
 *     in {@link CareTeamComponent#getProvider()}
 * @param practitionerIdValue the {@link Identifier#getValue()} of the practitioner to reference
 *     in {@link CareTeamComponent#getProvider()}
 * @param careTeamRole the {@link ClaimCareteamrole} to use for the {@link
 *     CareTeamComponent#getRole()}
 * @return the {@link CareTeamComponent} that was created/linked
 */
static CareTeamComponent addCareTeamPractitioner(ExplanationOfBenefit eob, ItemComponent eobItem, String practitionerIdSystem, String practitionerIdValue, ClaimCareteamrole careTeamRole) {
    // Try to find a matching pre-existing entry.
    CareTeamComponent careTeamEntry = eob.getCareTeam().stream().filter(ctc -> ctc.getProvider().hasIdentifier()).filter(ctc -> practitionerIdSystem.equals(ctc.getProvider().getIdentifier().getSystem()) && practitionerIdValue.equals(ctc.getProvider().getIdentifier().getValue())).filter(ctc -> ctc.hasRole()).filter(ctc -> careTeamRole.toCode().equals(ctc.getRole().getCodingFirstRep().getCode()) && careTeamRole.getSystem().equals(ctc.getRole().getCodingFirstRep().getSystem())).findAny().orElse(null);
    // If no match was found, add one to the EOB.
    if (careTeamEntry == null) {
        careTeamEntry = eob.addCareTeam();
        careTeamEntry.setSequence(eob.getCareTeam().size() + 1);
        careTeamEntry.setProvider(createIdentifierReference(practitionerIdSystem, practitionerIdValue));
        CodeableConcept careTeamRoleConcept = createCodeableConcept(ClaimCareteamrole.OTHER.getSystem(), careTeamRole.toCode());
        careTeamRoleConcept.getCodingFirstRep().setDisplay(careTeamRole.getDisplay());
        careTeamEntry.setRole(careTeamRoleConcept);
    }
    // care team entry is at eob level so no need to create item link id
    if (eobItem == null) {
        return careTeamEntry;
    }
    // Link the EOB.item to the care team entry (if it isn't already).
    final int careTeamEntrySequence = careTeamEntry.getSequence();
    if (eobItem.getCareTeamLinkId().stream().noneMatch(id -> id.getValue() == careTeamEntrySequence)) {
        eobItem.addCareTeamLinkId(careTeamEntrySequence);
    }
    return careTeamEntry;
}
Also used : Arrays(java.util.Arrays) CarrierClaimColumn(gov.cms.bfd.model.rif.CarrierClaimColumn) CcwCodebookInterface(gov.cms.bfd.model.codebook.model.CcwCodebookInterface) Identifier(org.hl7.fhir.dstu3.model.Identifier) Constants(ca.uhn.fhir.rest.api.Constants) Coding(org.hl7.fhir.dstu3.model.Coding) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) DomainResource(org.hl7.fhir.dstu3.model.DomainResource) IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) StringUtils(org.apache.commons.lang3.StringUtils) SNFClaimColumn(gov.cms.bfd.model.rif.SNFClaimColumn) BigDecimal(java.math.BigDecimal) SNFClaimLine(gov.cms.bfd.model.rif.SNFClaimLine) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) CarrierClaimLine(gov.cms.bfd.model.rif.CarrierClaimLine) Map(java.util.Map) ProcedureComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ProcedureComponent) CcwCodebookMissingVariable(gov.cms.bfd.model.codebook.data.CcwCodebookMissingVariable) TemporalPrecisionEnum(ca.uhn.fhir.model.api.TemporalPrecisionEnum) Value(gov.cms.bfd.model.codebook.model.Value) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) Coverage(org.hl7.fhir.dstu3.model.Coverage) IdDt(ca.uhn.fhir.model.primitive.IdDt) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) MedicareSegment(gov.cms.bfd.server.war.commons.MedicareSegment) Reference(org.hl7.fhir.dstu3.model.Reference) DiagnosisComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.DiagnosisComponent) InpatientClaimColumn(gov.cms.bfd.model.rif.InpatientClaimColumn) Set(java.util.Set) StandardCharsets(java.nio.charset.StandardCharsets) ZoneId(java.time.ZoneId) UncheckedIOException(java.io.UncheckedIOException) ReferralRequestStatus(org.hl7.fhir.dstu3.model.ReferralRequest.ReferralRequestStatus) Stream(java.util.stream.Stream) ReferralRequestRequesterComponent(org.hl7.fhir.dstu3.model.ReferralRequest.ReferralRequestRequesterComponent) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) HHAClaimLine(gov.cms.bfd.model.rif.HHAClaimLine) Money(org.hl7.fhir.dstu3.model.Money) ReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest) BenefitComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.BenefitComponent) IAnyResource(org.hl7.fhir.instance.model.api.IAnyResource) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) CCWUtils(gov.cms.bfd.server.war.commons.CCWUtils) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) ResourceType(org.hl7.fhir.dstu3.model.ResourceType) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) Period(org.hl7.fhir.dstu3.model.Period) CurrencyIdentifier(gov.cms.bfd.server.war.stu3.providers.BeneficiaryTransformer.CurrencyIdentifier) CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) OffsetLinkBuilder(gov.cms.bfd.server.war.commons.OffsetLinkBuilder) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) MetricRegistry(com.codahale.metrics.MetricRegistry) LinkBuilder(gov.cms.bfd.server.war.commons.LinkBuilder) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) SimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity) IOException(java.io.IOException) Observation(org.hl7.fhir.dstu3.model.Observation) InputStreamReader(java.io.InputStreamReader) FDADrugDataUtilityApp(gov.cms.bfd.server.war.FDADrugDataUtilityApp) SupportingInformationComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.SupportingInformationComponent) DMEClaimColumn(gov.cms.bfd.model.rif.DMEClaimColumn) Patient(org.hl7.fhir.dstu3.model.Patient) MDC(org.slf4j.MDC) BufferedReader(java.io.BufferedReader) IBaseHasExtensions(org.hl7.fhir.instance.model.api.IBaseHasExtensions) Bundle(org.hl7.fhir.dstu3.model.Bundle) Date(java.util.Date) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) LoggerFactory(org.slf4j.LoggerFactory) Extension(org.hl7.fhir.dstu3.model.Extension) ClaimCareteamrole(org.hl7.fhir.dstu3.model.codesystems.ClaimCareteamrole) Organization(org.hl7.fhir.dstu3.model.Organization) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) HHAClaimColumn(gov.cms.bfd.model.rif.HHAClaimColumn) BenefitBalanceComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.BenefitBalanceComponent) Collection(java.util.Collection) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) DiagnosisLabel(gov.cms.bfd.server.war.commons.Diagnosis.DiagnosisLabel) Quantity(org.hl7.fhir.dstu3.model.Quantity) UnsignedIntType(org.hl7.fhir.dstu3.model.UnsignedIntType) Objects(java.util.Objects) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) CareTeamComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.CareTeamComponent) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) LocalDate(java.time.LocalDate) Optional(java.util.Optional) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DateType(org.hl7.fhir.dstu3.model.DateType) OutpatientClaimColumn(gov.cms.bfd.model.rif.OutpatientClaimColumn) HospiceClaimLine(gov.cms.bfd.model.rif.HospiceClaimLine) DataFormatException(ca.uhn.fhir.parser.DataFormatException) HashMap(java.util.HashMap) InpatientClaimLine(gov.cms.bfd.model.rif.InpatientClaimLine) OutpatientClaimLine(gov.cms.bfd.model.rif.OutpatientClaimLine) HashSet(java.util.HashSet) ExplanationOfBenefitStatus(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ExplanationOfBenefitStatus) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) ObservationStatus(org.hl7.fhir.dstu3.model.Observation.ObservationStatus) InvalidRifValueException(gov.cms.bfd.model.rif.parse.InvalidRifValueException) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) DMEClaimLine(gov.cms.bfd.model.rif.DMEClaimLine) LinkedList(java.util.LinkedList) NoSuchElementException(java.util.NoSuchElementException) AdjudicationComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.AdjudicationComponent) BenefitCategory(org.hl7.fhir.dstu3.model.codesystems.BenefitCategory) Logger(org.slf4j.Logger) Resource(org.hl7.fhir.dstu3.model.Resource) Variable(gov.cms.bfd.model.codebook.model.Variable) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) Consumer(java.util.function.Consumer) URLEncoder(java.net.URLEncoder) IdentifierType(gov.cms.bfd.server.war.commons.IdentifierType) InputStream(java.io.InputStream) CareTeamComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.CareTeamComponent) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 10 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method createIdentifierReference.

/**
 * @param identifierType the {@link gov.cms.bfd.server.war.stu3.providers.IdentifierType}
 * @param identifierValue the {@link Identifier#getValue()} to use in {@link
 *     Reference#getIdentifier()}
 * @return a {@link Reference} with the specified {@link Identifier}
 */
static Reference createIdentifierReference(IdentifierType identifierType, String identifierValue) {
    Reference reference = new Reference();
    Coding coding = new Coding().setSystem(identifierType.getSystem()).setCode(identifierType.getCode()).setDisplay(identifierType.getDisplay());
    List<Coding> codingList = new ArrayList<Coding>();
    codingList.add(coding);
    CodeableConcept codeableConcept = new CodeableConcept().setCoding(codingList);
    return reference.setIdentifier(new Identifier().setSystem(identifierType.getSystem()).setValue(identifierValue).setType(codeableConcept)).setDisplay(retrieveNpiCodeDisplay(identifierValue));
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) CurrencyIdentifier(gov.cms.bfd.server.war.stu3.providers.BeneficiaryTransformer.CurrencyIdentifier) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

Identifier (org.hl7.fhir.r4.model.Identifier)203 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)143 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)125 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)116 Test (org.junit.Test)103 Test (org.junit.jupiter.api.Test)82 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)63 ArrayList (java.util.ArrayList)56 Reference (org.hl7.fhir.r4.model.Reference)53 Identifier (org.hl7.fhir.dstu3.model.Identifier)52 Patient (org.hl7.fhir.r4.model.Patient)52 Coding (org.hl7.fhir.r4.model.Coding)47 Date (java.util.Date)40 Practitioner (org.hl7.fhir.r4.model.Practitioner)40 List (java.util.List)39 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)38 Resource (org.hl7.fhir.r4.model.Resource)37 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)31 Collectors (java.util.stream.Collectors)30