/// <summary> /// Deserialize JSON into a FHIR EpisodeOfCare /// </summary> public static void DeserializeJson(this EpisodeOfCare current, ref Utf8JsonReader reader, JsonSerializerOptions options) { string propertyName; while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return; } if (reader.TokenType == JsonTokenType.PropertyName) { propertyName = reader.GetString(); if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug) { Console.WriteLine($"EpisodeOfCare >>> EpisodeOfCare.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"EpisodeOfCare: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
internal int _UpdateAttendingDr(EpisodeOfCare model) { string host = ConfigurationManager.AppSettings["DatabaseHost"]; string user = ConfigurationManager.AppSettings["DatabaseUser"]; string name = ConfigurationManager.AppSettings["DatabaseName"]; string password = ConfigurationManager.AppSettings["DatabasePassword"]; string connectionString = $"data source={host};Initial Catalog={name};User ID={user};Password={Crypto.Decrypt(password)};"; using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand("[EPONS].[UpdateDoctor]", conn)) { cmd.CommandType = CommandType.StoredProcedure; // set up the parameters cmd.Parameters.Add("@doctorName", SqlDbType.VarChar, 256).Value = model.AttendingDoctorName ?? ""; cmd.Parameters.Add("@contactNumber", SqlDbType.VarChar, 64).Value = model.AttendingDoctorNumber ?? ""; cmd.Parameters.Add("@emailAddress", SqlDbType.VarChar, 256).Value = model.AttendingDoctorEmail ?? ""; cmd.Parameters.Add("@practiceName", SqlDbType.VarChar, 256).Value = model.AttendingDoctorPracticeName ?? ""; cmd.Parameters.Add("@hpcsaNumber", SqlDbType.VarChar, 256).Value = model.AttendingDoctorHPCSANumber ?? ""; cmd.Parameters.Add("@doctorId", SqlDbType.Int).Value = model.AttendingDoctorId; // open connection and execute stored procedure conn.Open(); int a = cmd.ExecuteNonQuery(); // read output value from @doctorId conn.Close(); return(a); } }
internal void _CreateEpisodeOfCare(EpisodeOfCare model) { if (model.ReferringDoctorName != null) { model.ReferringDoctorId = _CreateRefferingDr(model); } if (model.AttendingDoctorName != null) { model.AttendingDoctorId = _CreateAttendingDr(model); } Execute("[EPONS].[CreateEpisodeOfCare]", new { patientId = model.PatientId, facilityId = model.FacilityId, userId = model.userId, reasonForAdmissionId = model.ReasonForAdmissionId, reasonForAdmissionTimestamp = model.ReasonForAdmissionTimestamp, allocationNumber = model.AllocationNumber, impairmentGroupId = model.ImpairmentGroupId, admissionTypeId = model.AdmissionTypeId, referringDoctorId = model.ReferringDoctorId, attendingDoctorId = model.AttendingDoctorId }); }
public ReadEpisodeOfCareQueryLastUpdated(EpisodeOfCare episodeOfCare) { if (episodeOfCare == null) { throw new ArgumentNullException(nameof(episodeOfCare)); } EpisodeOfCare = episodeOfCare; }
public UpsertEpisodeOfCareCommand(EpisodeOfCare episodeOfCare, string patientId) { if (episodeOfCare == null) { throw new ArgumentNullException(nameof(episodeOfCare)); } if (string.IsNullOrWhiteSpace(patientId) == true) { throw new ArgumentNullException(nameof(patientId)); } EpisodeOfCare = episodeOfCare; PatientId = patientId; }
public UpsertEocConditionCommand(EpisodeOfCare episodeOfCare, string conditionId) { if (episodeOfCare == null) { throw new ArgumentNullException(nameof(episodeOfCare)); } if (conditionId == null) { throw new ArgumentNullException(nameof(conditionId)); } EpisodeOfCare = episodeOfCare; ConditionId = conditionId; }
internal int _UpdateEpisodeOfCare(EpisodeOfCare model) { string host = ConfigurationManager.AppSettings["DatabaseHost"]; string user = ConfigurationManager.AppSettings["DatabaseUser"]; string name = ConfigurationManager.AppSettings["DatabaseName"]; string password = ConfigurationManager.AppSettings["DatabasePassword"]; string connectionString = $"data source={host};Initial Catalog={name};User ID={user};Password={Crypto.Decrypt(password)};"; using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand("[EPONS].[UpdateEpisodeOfCare] ", conn)) { cmd.CommandType = CommandType.StoredProcedure; // set up the parameters cmd.Parameters.Add("@episodeOfCareId", SqlDbType.UniqueIdentifier, 256).Value = model.EpisodeOfCareId; cmd.Parameters.Add("@patientId", SqlDbType.UniqueIdentifier, 256).Value = model.PatientId; cmd.Parameters.Add("@facilityId", SqlDbType.UniqueIdentifier, 256).Value = model.FacilityId; cmd.Parameters.Add("@reasonForAdmissionId", SqlDbType.UniqueIdentifier, 256).Value = model.ReasonForAdmissionId; cmd.Parameters.Add("@reasonForAdmissionTimestamp", SqlDbType.Date, 256).Value = model.ReasonForAdmissionTimestamp; cmd.Parameters.Add("@allocationNumber", SqlDbType.VarChar, 60).Value = model.AllocationNumber; cmd.Parameters.Add("@impairmentGroupId", SqlDbType.UniqueIdentifier, 256).Value = model.ImpairmentGroupId; cmd.Parameters.Add("@admissionTypeId", SqlDbType.UniqueIdentifier, 256).Value = model.AdmissionTypeId; cmd.Parameters.Add("@referringDoctorId", SqlDbType.Int, 6).Value = model.ReferringDoctorId; cmd.Parameters.Add("@attendingDoctorId", SqlDbType.Int, 6).Value = model.AttendingDoctorId; cmd.Parameters.Add("@DischargeTypeId", SqlDbType.UniqueIdentifier, 256).Value = model.DischargeTypeId; cmd.Parameters.Add("@deallocationTimestamp", SqlDbType.DateTime).Value = model.DeallocationTimestamp; // open connection and execute stored procedure conn.Open(); int a = cmd.ExecuteNonQuery(); // read output value from @doctorId conn.Close(); return(a); } }
public UpsertEocConditionCommand(EpisodeOfCare episodeOfCare, Condition condition) : this(episodeOfCare, condition.Id) { }
/// <summary> /// Serialize a FHIR EpisodeOfCare into JSON /// </summary> public static void SerializeJson(this EpisodeOfCare current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } writer.WriteString("resourceType", "EpisodeOfCare"); // Complex: EpisodeOfCare, Export: EpisodeOfCare, Base: DomainResource (DomainResource) ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false); if ((current.Identifier != null) && (current.Identifier.Count != 0)) { writer.WritePropertyName("identifier"); writer.WriteStartArray(); foreach (Identifier val in current.Identifier) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value)); if ((current.StatusHistory != null) && (current.StatusHistory.Count != 0)) { writer.WritePropertyName("statusHistory"); writer.WriteStartArray(); foreach (EpisodeOfCare.StatusHistoryComponent val in current.StatusHistory) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Type != null) && (current.Type.Count != 0)) { writer.WritePropertyName("type"); writer.WriteStartArray(); foreach (CodeableConcept val in current.Type) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Diagnosis != null) && (current.Diagnosis.Count != 0)) { writer.WritePropertyName("diagnosis"); writer.WriteStartArray(); foreach (EpisodeOfCare.DiagnosisComponent val in current.Diagnosis) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } writer.WritePropertyName("patient"); current.Patient.SerializeJson(writer, options); if (current.ManagingOrganization != null) { writer.WritePropertyName("managingOrganization"); current.ManagingOrganization.SerializeJson(writer, options); } if (current.Period != null) { writer.WritePropertyName("period"); current.Period.SerializeJson(writer, options); } if ((current.ReferralRequest != null) && (current.ReferralRequest.Count != 0)) { writer.WritePropertyName("referralRequest"); writer.WriteStartArray(); foreach (ResourceReference val in current.ReferralRequest) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.CareManager != null) { writer.WritePropertyName("careManager"); current.CareManager.SerializeJson(writer, options); } if ((current.Team != null) && (current.Team.Count != 0)) { writer.WritePropertyName("team"); writer.WriteStartArray(); foreach (ResourceReference val in current.Team) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Account != null) && (current.Account.Count != 0)) { writer.WritePropertyName("account"); writer.WriteStartArray(); foreach (ResourceReference val in current.Account) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR EpisodeOfCare /// </summary> public static void DeserializeJsonProperty(this EpisodeOfCare current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "identifier": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"EpisodeOfCare error reading 'identifier' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Identifier = new List <Identifier>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Identifier v_Identifier = new Hl7.Fhir.Model.Identifier(); v_Identifier.DeserializeJson(ref reader, options); current.Identifier.Add(v_Identifier); if (!reader.Read()) { throw new JsonException($"EpisodeOfCare error reading 'identifier' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Identifier.Count == 0) { current.Identifier = null; } break; case "status": if (reader.TokenType == JsonTokenType.Null) { current.StatusElement = new Code <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>(); reader.Skip(); } else { current.StatusElement = new Code <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>(reader.GetString())); } break; case "_status": if (current.StatusElement == null) { current.StatusElement = new Code <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>(); } ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options); break; case "statusHistory": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"EpisodeOfCare error reading 'statusHistory' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.StatusHistory = new List <EpisodeOfCare.StatusHistoryComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.EpisodeOfCare.StatusHistoryComponent v_StatusHistory = new Hl7.Fhir.Model.EpisodeOfCare.StatusHistoryComponent(); v_StatusHistory.DeserializeJson(ref reader, options); current.StatusHistory.Add(v_StatusHistory); if (!reader.Read()) { throw new JsonException($"EpisodeOfCare error reading 'statusHistory' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.StatusHistory.Count == 0) { current.StatusHistory = null; } break; case "type": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"EpisodeOfCare error reading 'type' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Type = new List <CodeableConcept>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.CodeableConcept v_Type = new Hl7.Fhir.Model.CodeableConcept(); v_Type.DeserializeJson(ref reader, options); current.Type.Add(v_Type); if (!reader.Read()) { throw new JsonException($"EpisodeOfCare error reading 'type' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Type.Count == 0) { current.Type = null; } break; case "diagnosis": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"EpisodeOfCare error reading 'diagnosis' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Diagnosis = new List <EpisodeOfCare.DiagnosisComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.EpisodeOfCare.DiagnosisComponent v_Diagnosis = new Hl7.Fhir.Model.EpisodeOfCare.DiagnosisComponent(); v_Diagnosis.DeserializeJson(ref reader, options); current.Diagnosis.Add(v_Diagnosis); if (!reader.Read()) { throw new JsonException($"EpisodeOfCare error reading 'diagnosis' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Diagnosis.Count == 0) { current.Diagnosis = null; } break; case "patient": current.Patient = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Patient).DeserializeJson(ref reader, options); break; case "managingOrganization": current.ManagingOrganization = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.ManagingOrganization).DeserializeJson(ref reader, options); break; case "period": current.Period = new Hl7.Fhir.Model.Period(); ((Hl7.Fhir.Model.Period)current.Period).DeserializeJson(ref reader, options); break; case "referralRequest": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"EpisodeOfCare error reading 'referralRequest' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.ReferralRequest = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_ReferralRequest = new Hl7.Fhir.Model.ResourceReference(); v_ReferralRequest.DeserializeJson(ref reader, options); current.ReferralRequest.Add(v_ReferralRequest); if (!reader.Read()) { throw new JsonException($"EpisodeOfCare error reading 'referralRequest' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.ReferralRequest.Count == 0) { current.ReferralRequest = null; } break; case "careManager": current.CareManager = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.CareManager).DeserializeJson(ref reader, options); break; case "team": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"EpisodeOfCare error reading 'team' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Team = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Team = new Hl7.Fhir.Model.ResourceReference(); v_Team.DeserializeJson(ref reader, options); current.Team.Add(v_Team); if (!reader.Read()) { throw new JsonException($"EpisodeOfCare error reading 'team' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Team.Count == 0) { current.Team = null; } break; case "account": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"EpisodeOfCare error reading 'account' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Account = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Account = new Hl7.Fhir.Model.ResourceReference(); v_Account.DeserializeJson(ref reader, options); current.Account.Add(v_Account); if (!reader.Read()) { throw new JsonException($"EpisodeOfCare error reading 'account' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Account.Count == 0) { current.Account = null; } break; // Complex: EpisodeOfCare, Export: EpisodeOfCare, Base: DomainResource default: ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }