public ActionResult JoinRealm() { var bundle = new Bundle(); var person = new Person { Key = Guid.NewGuid(), Names = new List <EntityName> { new EntityName(NameUseKeys.OfficialRecord, "smith", "mary") } }; var patient = new Patient { Relationships = new List <EntityRelationship> { new EntityRelationship(EntityRelationshipTypeKeys.Mother, Guid.NewGuid()) } }; var test = new ActParticipation(ActParticipationKey.RecordTarget, Guid.NewGuid()); var test1 = new ActParticipation(ActParticipationKey.Location, Guid.Parse("880d2a08-8e94-402b-84b6-cb3bc0a576a9")); var test2 = new ActParticipation(ActParticipationKey.Performer, Guid.Parse("6ba47c4c-ec52-46a9-b2d9-ad3104ef238f")); var test3 = new ActParticipation(ActParticipationKey.Authororiginator, Guid.Parse("6ba47c4c-ec52-46a9-b2d9-ad3104ef238f")); var test4 = new ActParticipation(ActParticipationKey.Consumable, Guid.Parse("a14dd78e-1f68-40e0-a59f-cd1e64f720b8")); var test5 = new ActParticipation(ActParticipationKey.Consumable, Guid.Parse("ecda818f-e7b7-466a-9a71-a79eb2241ac9")); var act = new SubstanceAdministration { CreationTime = DateTimeOffset.Now, Key = Guid.NewGuid(), MoodConceptKey = ActMoodKeys.Eventoccurrence, Participations = new List <ActParticipation> { test, test1, test2, test3, test4, test5 } }; bundle.Item.Add(person); bundle.Item.Add(patient); bundle.Item.Add(act); bundle.Item.Add(test); bundle.Item.Add(test1); bundle.Item.Add(test2); bundle.Item.Add(test3); bundle.Item.Add(test4); bundle.Item.Add(test5); var content = JsonConvert.SerializeObject(bundle); return(View()); }
public void TestCanMapObject() { var initialImmunizationKey = Guid.Parse("f3be6b88-bc8f-4263-a779-86f21ea10a47"); var immunizationKey = Guid.Parse("6e7a3521-2967-4c0a-80ec-6c5c197b2178"); var boosterImmunizationKey = Guid.Parse("0331e13f-f471-4fbd-92dc-66e0a46239d5"); var randomGuidKey = Guid.NewGuid(); var localizationService = ApplicationServiceContext.Current.GetService <ILocalizationService>(); var immunizationResourceHandler = new ImmunizationResourceHandler(m_substanceAdministrationRepositoryService, localizationService); //check to ensure immunization instance can be mapped var result = immunizationResourceHandler.CanMapObject(new Immunization()); Assert.True(result); //check to ensure an invalid instance cannot be mapped result = immunizationResourceHandler.CanMapObject(new Medication()); Assert.False(result); //check to ensure substance instance can be mapped with valid type keys var substanceAdministration = new SubstanceAdministration() { TypeConcept = new Concept() { Key = initialImmunizationKey } }; result = immunizationResourceHandler.CanMapObject(substanceAdministration); Assert.True(result); //check to ensure substance instance can be mapped with valid type keys substanceAdministration.TypeConcept = new Concept() { Key = boosterImmunizationKey }; result = immunizationResourceHandler.CanMapObject(substanceAdministration); Assert.True(result); //check to ensure substance instance can be mapped with valid type keys substanceAdministration.TypeConcept = new Concept() { Key = immunizationKey }; result = immunizationResourceHandler.CanMapObject(substanceAdministration); Assert.True(result); //check to ensure substance instance cannot be mapped without valid key substanceAdministration.TypeConcept = new Concept() { Key = randomGuidKey }; result = immunizationResourceHandler.CanMapObject(substanceAdministration); Assert.False(result); }
/// <inheritdoc/> protected override Act MapToModel(AdverseEvent resource) { #if !DEBUG throw new NotSupportedException(); #endif var retVal = new Act(); if (!Guid.TryParse(resource.Id, out var key)) { key = Guid.NewGuid(); } retVal.ClassConceptKey = ActClassKeys.Act; // retVal.StatusConceptKey = StatusKeys.Active; retVal.Key = key; retVal.MoodConceptKey = ActMoodKeys.Eventoccurrence; // map identifier to identifiers retVal.Identifiers.Add(DataTypeConverter.ToActIdentifier(resource.Identifier)); /* retVal.Identifiers = new List<ActIdentifier> * { * DataTypeConverter.ToActIdentifier(resource.Identifier) * };*/ //map category to type concept retVal.TypeConcept = DataTypeConverter.ToConcept(resource.Category.FirstOrDefault()); // map subject to patient if (resource.Subject != null) { retVal.Participations.Add(resource.Subject.Reference.StartsWith("urn:uuid:") ? new ActParticipation(ActParticipationKey.RecordTarget, Guid.Parse(resource.Subject.Reference.Substring(9))): new ActParticipation(ActParticipationKey.RecordTarget, DataTypeConverter.ResolveEntity <Core.Model.Roles.Patient>(resource.Subject, resource))); } // map date element to act time var occurTime = (DateTimeOffset)DataTypeConverter.ToDateTimeOffset(resource.DateElement); var targetAct = new CodedObservation() { ActTime = occurTime }; retVal.Relationships.Add(new ActRelationship(ActRelationshipTypeKeys.HasSubject, targetAct)); retVal.ActTime = occurTime; // map event to relationships var reactionTarget = new CodedObservation() { Value = DataTypeConverter.ToConcept(resource.Event) }; targetAct.Relationships.Add(new ActRelationship(ActRelationshipTypeKeys.HasManifestation, reactionTarget)); // map location to place if (resource.Location != null) { retVal.Participations.Add(resource.Location.Reference.StartsWith("urn:uuid:") ? new ActParticipation(ActParticipationKey.Location, Guid.Parse(resource.Location.Reference.Substring(9))) : new ActParticipation(ActParticipationKey.Location, DataTypeConverter.ResolveEntity <Core.Model.Entities.Place>(resource.Location, resource))); // retVal.Participations.Add(new ActParticipation(ActParticipationKey.Location, DataTypeConverter.ResolveEntity<Core.Model.Entities.Place>(resource.Location, resource))); } // map seriousness to relationships if (resource.Severity != null) { var severityTarget = new CodedObservation() { Value = DataTypeConverter.ToConcept(resource.Severity.Coding.FirstOrDefault(), "http://terminology.hl7.org/CodeSystem/adverse-event-severity"), TypeConceptKey = ObservationTypeKeys.Severity }; targetAct.Relationships.Add(new ActRelationship(ActRelationshipTypeKeys.HasComponent, severityTarget)); } // map recoder to provider if (resource.Recorder != null) { retVal.Participations.Add(resource.Recorder.Reference.StartsWith("urn:uuid:") ? new ActParticipation(ActParticipationKey.Authororiginator, Guid.Parse(resource.Recorder.Reference.Substring(9))) : new ActParticipation(ActParticipationKey.Authororiginator, DataTypeConverter.ResolveEntity <Core.Model.Roles.Provider>(resource.Recorder, resource))); // retVal.Participations.Add(new ActParticipation(ActParticipationKey.Authororiginator, DataTypeConverter.ResolveEntity<Core.Model.Roles.Provider>(resource.Recorder, resource))); } // map outcome to status concept key or relationships if (resource.Outcome != null) { if (resource.Outcome.Coding.Any(o => o.System == "http://hl7.org/fhir/adverse-event-outcome")) { if (resource.Outcome.Coding.Any(o => o.Code == "fatal")) { retVal.Relationships.Add(new ActRelationship(ActRelationshipTypeKeys.IsCauseOf, new CodedObservation { TypeConceptKey = ObservationTypeKeys.ClinicalState, ValueKey = Guid.Parse("6df3720b-857f-4ba2-826f-b7f1d3c3adbb") })); } else if (resource.Outcome.Coding.Any(o => o.Code == "ongoing")) { retVal.StatusConceptKey = StatusKeys.Active; } else if (resource.Outcome.Coding.Any(o => o.Code == "resolved")) { retVal.StatusConceptKey = StatusKeys.Completed; } } } // map instance to relationships and participations if (resource.SuspectEntity != null) { foreach (var component in resource.SuspectEntity) { var adm = new SubstanceAdministration(); if (component.Instance.GetType() == typeof(Medication)) { adm.Participations.Add(component.Instance.Reference.StartsWith("urn:uuid:") ? new ActParticipation(ActParticipationKey.Consumable, Guid.Parse(component.Instance.Reference.Substring(9))) : new ActParticipation(ActParticipationKey.Consumable, DataTypeConverter.ResolveEntity <Core.Model.Entities.ManufacturedMaterial>(component.Instance, resource))); // adm.Participations.Add(new ActParticipation(ActParticipationKey.Consumable, DataTypeConverter.ResolveEntity<Core.Model.Entities.ManufacturedMaterial>(component.Instance, resource))); retVal.Relationships.Add(new ActRelationship(ActRelationshipTypeKeys.RefersTo, adm)); } else if (component.Instance.GetType() == typeof(Substance)) { adm.Participations.Add((component.Instance.Reference.StartsWith("urn:uuid:") ? new ActParticipation(ActParticipationKey.Product, Guid.Parse(component.Instance.Reference.Substring(9))) : new ActParticipation(ActParticipationKey.Product, DataTypeConverter.ResolveEntity <Core.Model.Entities.Material>(component.Instance, resource)))); // adm.Participations.Add(new ActParticipation(ActParticipationKey.Product, DataTypeConverter.ResolveEntity<Core.Model.Entities.Material>(component.Instance, resource))); retVal.Relationships.Add(new ActRelationship(ActRelationshipTypeKeys.RefersTo, adm)); } } } return(retVal); }
/// <summary> /// Save sbadm /// </summary> public SubstanceAdministration Save(SubstanceAdministration data) { return(this.Save <SubstanceAdministration>(data)); }
/// <summary> /// Insert SBADM /// </summary> public SubstanceAdministration Insert(SubstanceAdministration data) { return(this.Insert <SubstanceAdministration>(data)); }
private static SubstanceAdministration MakeSubstanceAdministration(string section) { SubstanceAdministration sa = new SubstanceAdministration(); if (section == "IMMUNIZATIONS") { sa.TemplateId = new LIST<II>(); sa.TemplateId.Add(new II("2.16.840.1.113883.10.20.22.4.52")); sa.Id = new SET<II>(new II(new Guid())); sa.StatusCode = new CS<ActStatus>(ActStatus.Completed); sa.EffectiveTime.Add(new GTS()); //It automatically adds class code sa.MoodCode = new CS<x_DocumentSubstanceMood>(x_DocumentSubstanceMood.Eventoccurrence); sa.NegationInd = true; sa.Consumable = MakeConsumable("IMMUNIZATIONS"); } if (section == "MEDICATIONS") { sa.MoodCode = new CS<x_DocumentSubstanceMood>(x_DocumentSubstanceMood.Eventoccurrence); sa.TemplateId = new LIST<II>(); sa.TemplateId.Add(new II("2.16.840.1.113883.10.20.22.4.16")); sa.Id = new SET<II>(new II(new Guid())); sa.Text = new ED(); sa.Text.Reference = new TEL("#medication1"); sa.StatusCode = new CS<ActStatus>(ActStatus.Active); //TODO: sa.EffectiveTime = new List<GTS>(); sa.EffectiveTime.Add(new GTS(new IVL<TS>(new TS(DateTime.Today), new TS(DateTime.Today)))); PIVL<TS> p = new PIVL<TS>(); p.InstitutionSpecified = true; p.Operator = SetOperator.A; p.Period = new PQ(24.0m, "h"); sa.EffectiveTime.Add(new GTS(p)); sa.RouteCode = new CE<string>( "C38288", "2.16.840.1.113883.3.26.1.1", "NCI Thesaurus", null, "oral", null); sa.DoseQuantity = new IVL<PQ>(new PQ()); sa.AdministrationUnitCode = new CE<string>( "C42998", "2.16.840.1.113883.3.26.1.1", "NCI Thesaurus", null, "tablet", null); sa.Consumable = MakeConsumable("MEDICATIONS"); } return sa; }