Skip to content

Commit

Permalink
feat(bfdr): fetal death feature (#185)
Browse files Browse the repository at this point in the history
Adds fetal death and fetal death messaging to the bfdr library.

---------

Co-authored-by: Tricia Tran <[email protected]>
Co-authored-by: Robert Passas <[email protected]>
Co-authored-by: pkmitre <[email protected]>
Co-authored-by: RobertScalfani <[email protected]>
  • Loading branch information
5 people authored Nov 5, 2024
1 parent 7471b65 commit ba4cd43
Show file tree
Hide file tree
Showing 128 changed files with 31,804 additions and 10,901 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/bfdr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- Natality-feature
- fetal-death-feature
paths:
- 'projects/BFDR/**'
- 'projects/BFDR.CLI/**'
Expand All @@ -14,6 +15,7 @@ on:
branches:
- main
- Natality-feature
- fetal-death-feature
paths:
- 'projects/BFDR/**'
- 'projects/BFDR.CLI/**'
Expand Down Expand Up @@ -80,4 +82,4 @@ jobs:
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
path: code-coverage-results.md
4 changes: 2 additions & 2 deletions .github/workflows/canary-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Canary Testing

on:
push:
branches: [ main, Natality-feature ]
branches: [ main, Natality-feature, fetal-death-feature ]
paths:
- 'projects/Canary/**'
- 'projects/Canary.Tests/**'
pull_request:
branches: [ main, Natality-feature ]
branches: [ main, Natality-feature, fetal-death-feature ]
paths:
- 'projects/Canary/**'
- 'projects/Canary.Tests/**'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/vrdr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- Natality-feature
- fetal-death-feature
paths:
- 'projects/VRDR/**'
- 'projects/VRDR.CLI/**'
Expand All @@ -16,6 +17,7 @@ on:
branches:
- main
- Natality-feature
- fetal-death-feature
paths:
- 'projects/VRDR/**'
- 'projects/VRDR.CLI/**'
Expand Down
168 changes: 142 additions & 26 deletions projects/BFDR.CLI/Program.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion projects/BFDR.Messaging/BFDR.Messaging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Target Name="GenerateCustomPropertyFile" BeforeTargets="BeforeCompile">
<WriteLinesToFile
File="GeneratedCustomProperty.cs"
Lines="/// &lt;summary&gt;Generated file from VRDR.Messaging.csproj&lt;/summary&gt;;public static class GeneratedCustomProperty {;/// &lt;summary&gt;Payload Version Identifier&lt;/summary&gt;;public const string Value = &quot;$(PayloadVersionID)&quot;%3B}"
Lines="/// &lt;summary&gt;Generated file from BFDR.Messaging.csproj&lt;/summary&gt;;public static class GeneratedCustomProperty {;/// &lt;summary&gt;Payload Version Identifier&lt;/summary&gt;;public const string Value = &quot;$(PayloadVersionID)&quot;%3B}"
Overwrite="true" />
</Target>
</Project>
142 changes: 142 additions & 0 deletions projects/BFDR.Messaging/BFDRAcknowledgementMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
using Hl7.Fhir.Model;

namespace BFDR
{
/// <summary>Class <c>BirthRecordAcknowledgementMessage</c> supports the acknowledgment of other messages.</summary>
public class BirthRecordAcknowledgementMessage : BFDRAcknowledgementMessage
{
/// <summary>
/// The Event URI for BirthRecordAcknowledgementMessage
/// </summary>
public new const string MESSAGE_TYPE = "http://nchs.cdc.gov/birth_acknowledgement";

/// <summary>Default constructor that creates a new, empty BirthRecordAcknowledgementMessage.</summary>
public BirthRecordAcknowledgementMessage(BFDRBaseMessage message) : base(message)
{
MessageType = MESSAGE_TYPE;
}
/// <summary>Constructor that creates a BirthRecordAcknowledgementMessage from a bundle.</summary>
internal BirthRecordAcknowledgementMessage(Bundle messageBundle) : base(messageBundle)
{
MessageType = MESSAGE_TYPE;
}

/// <summary>Constructor that creates an acknowledgement for the specified message.</summary>
/// <param name="messageId">the id of the message to create an acknowledgement for.</param>
/// <param name="destination">the endpoint identifier that the ack message will be sent to.</param>
/// <param name="source">the endpoint identifier that the ack message will be sent from.</param>
public BirthRecordAcknowledgementMessage(string messageId, string destination, string source = "http://nchs.cdc.gov/bfdr_submission") : base(messageId, destination, source)
{
MessageType = MESSAGE_TYPE;
}
}
/// <summary>Class <c>FetalDeathRecordAcknowledgementMessage</c> supports the acknowledgment of other messages.</summary>
public class FetalDeathRecordAcknowledgementMessage : BFDRAcknowledgementMessage
{
/// <summary>
/// The Event URI for FetalDeathRecordAcknowledgementMessage
/// </summary>
public new const string MESSAGE_TYPE = "http://nchs.cdc.gov/fd_acknowledgement";
/// <summary>Default constructor that creates a new, empty FetalDeathRecordAcknowledgementMessage.</summary>
public FetalDeathRecordAcknowledgementMessage(BFDRBaseMessage message) : base(message)
{
MessageType = MESSAGE_TYPE;
}
/// <summary>Constructor that creates a FetalDeathRecordAcknowledgementMessage from a bundle.</summary>
internal FetalDeathRecordAcknowledgementMessage(Bundle messageBundle) : base(messageBundle)
{
MessageType = MESSAGE_TYPE;
}

/// <summary>Constructor that creates an acknowledgement for the specified message.</summary>
/// <param name="messageId">the id of the message to create an acknowledgement for.</param>
/// <param name="destination">the endpoint identifier that the ack message will be sent to.</param>
/// <param name="source">the endpoint identifier that the ack message will be sent from.</param>
public FetalDeathRecordAcknowledgementMessage(string messageId, string destination, string source = "http://nchs.cdc.gov/bfdr_submission") : base(messageId, destination, source)
{
MessageType = MESSAGE_TYPE;
}
}
/// <summary>Class <c>BFDRAcknowledgementMessage</c> supports the acknowledgment of other messages.</summary>
public abstract class BFDRAcknowledgementMessage : BFDRBaseMessage
{

/// <summary>Constructor that creates an acknowledgement for the specified message.</summary>
/// <param name="messageToAck">the message to create an acknowledgement for.</param>
public BFDRAcknowledgementMessage(BFDRBaseMessage messageToAck) : this(messageToAck?.MessageId, messageToAck?.MessageSource, messageToAck?.MessageDestination)
{
this.CertNo = messageToAck?.CertNo;
this.StateAuxiliaryId = messageToAck?.StateAuxiliaryId;
this.JurisdictionId = messageToAck?.JurisdictionId;
this.EventYear = messageToAck?.GetYear();
this.PayloadVersionId = $"{GeneratedCustomProperty.Value}";

if(typeof(BFDRVoidMessage).IsInstanceOfType(messageToAck))
{
BFDRVoidMessage voidMessageToAck = (BFDRVoidMessage) messageToAck;
this.BlockCount = voidMessageToAck?.BlockCount;
}
}

/// <summary>
/// Construct an BFDRAcknowledgementMessage from a FHIR Bundle.
/// </summary>
/// <param name="messageBundle">a FHIR Bundle that will be used to initialize the BFDRAcknowledgementMessage</param>
/// <returns></returns>
internal BFDRAcknowledgementMessage(Bundle messageBundle) : base(messageBundle)
{
// no payload for Ack message
}

/// <summary>Constructor that creates an acknowledgement for the specified message.</summary>
/// <param name="messageId">the id of the message to create an acknowledgement for.</param>
/// <param name="destination">the endpoint identifier that the ack message will be sent to.</param>
/// <param name="source">the endpoint identifier that the ack message will be sent from.</param>
public BFDRAcknowledgementMessage(string messageId, string destination, string source = "http://nchs.cdc.gov/bfdr_submission") : base(MESSAGE_TYPE)
{
Header.Source.Endpoint = source;
this.MessageDestination = destination;
MessageHeader.ResponseComponent resp = new MessageHeader.ResponseComponent();
resp.Identifier = messageId;
resp.Code = MessageHeader.ResponseType.Ok;
Header.Response = resp;
}

/// <summary>The id of the message that is being acknowledged by this message</summary>
/// <value>the message id.</value>
public string AckedMessageId
{
get
{
return Header?.Response?.Identifier;
}
set
{
if (Header.Response == null)
{
Header.Response = new MessageHeader.ResponseComponent();
Header.Response.Code = MessageHeader.ResponseType.Ok;
}
Header.Response.Identifier = value;
}
}

/// <summary>The number of records to void starting at the certificate number specified by the `CertNo` parameter</summary>
public uint? BlockCount
{
get
{
return (uint?)Record?.GetSingleValue<PositiveInt>("block_count")?.Value;
}
set
{
Record.Remove("block_count");
if (value != null && value > 1)
{
Record.Add("block_count", new PositiveInt((int)value));
}
}
}

}
}
Loading

0 comments on commit ba4cd43

Please sign in to comment.