Skip to content

Commit

Permalink
OIZ-58 added dataset classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nityan Khanna committed May 7, 2018
1 parent 2e6609e commit e5cf2aa
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 0 deletions.
51 changes: 51 additions & 0 deletions OpenIZAdmin.Services/Dataset/DataAssociation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2016-2018 Mohawk College of Applied Arts and Technology
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* User: khannan
* Date: 2018-5-7
*/

using System.Xml.Serialization;

namespace OpenIZAdmin.Services.Dataset
{
/// <summary>
/// Represents a data association action.
/// </summary>
/// <seealso cref="OpenIZAdmin.Services.Dataset.DataInstallAction" />
[XmlType(nameof(DataAssociation), Namespace = "http:https://openiz.org/data")]
public class DataAssociation : DataInstallAction
{
/// <summary>
/// Initializes a new instance of the <see cref="DataAssociation" /> class.
/// </summary>
public DataAssociation()
{
}

/// <summary>
/// Gets the action name
/// </summary>
/// <value>The name of the action.</value>
public override string ActionName => "Add";

/// <summary>
/// Gets or sets the name of the property.
/// </summary>
/// <value>The name of the property.</value>
[XmlAttribute("property")]
public string PropertyName { get; set; }
}
}
51 changes: 51 additions & 0 deletions OpenIZAdmin.Services/Dataset/DataInsert.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2016-2018 Mohawk College of Applied Arts and Technology
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* User: khannan
* Date: 2018-5-7
*/

using System.Xml.Serialization;

namespace OpenIZAdmin.Services.Dataset
{
/// <summary>
/// Represents a data insert action.
/// </summary>
/// <seealso cref="OpenIZAdmin.Services.Dataset.DataInstallAction" />
[XmlType(nameof(DataInsert), Namespace = "http:https://openiz.org/data")]
public class DataInsert : DataInstallAction
{
/// <summary>
/// Initializes a new instance of the <see cref="DataInsert"/> class.
/// </summary>
public DataInsert()
{
}

/// <summary>
/// Gets the name of the action.
/// </summary>
/// <value>The name of the action.</value>
public override string ActionName => "Insert";

/// <summary>
/// Gets or sets a value indicating whether the insert should be skipped if it exists.
/// </summary>
/// <value><c>true</c> if the insert should be skipped if it exists; otherwise, <c>false</c>.</value>
[XmlAttribute("skipIfExists")]
public bool SkipIfExists { get; set; }
}
}
96 changes: 96 additions & 0 deletions OpenIZAdmin.Services/Dataset/DataInstallAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2016-2018 Mohawk College of Applied Arts and Technology
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* User: khannan
* Date: 2018-5-7
*/

using OpenIZ.Core.Model;
using OpenIZ.Core.Model.Acts;
using OpenIZ.Core.Model.Collection;
using OpenIZ.Core.Model.DataTypes;
using OpenIZ.Core.Model.Entities;
using OpenIZ.Core.Model.Roles;
using OpenIZ.Core.Model.Security;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace OpenIZAdmin.Services.Dataset
{
/// <summary>
/// Represents a data install action.
/// </summary>
[XmlType(nameof(DataInstallAction), Namespace = "http:https://openiz.org/data")]
public abstract class DataInstallAction
{
/// <summary>
/// Gets the name of the action.
/// </summary>
/// <value>The name of the action.</value>
public abstract string ActionName { get; }

/// <summary>
/// Gets or sets the association which is the specified data for stuff that cannot be serialized.
/// </summary>
/// <value>The association.</value>
[XmlElement("associate")]
public List<DataAssociation> Association { get; set; }

/// <summary>
/// Gets the elements to be acted upon.
/// </summary>
/// <value>The element.</value>
[XmlElement("ConceptReferenceTerm", typeof(ConceptReferenceTerm), Namespace = "http:https://openiz.org/model")]
[XmlElement("ConceptName", typeof(ConceptName), Namespace = "http:https://openiz.org/model")]
[XmlElement("EntityRelationship", typeof(EntityRelationship), Namespace = "http:https://openiz.org/model")]
[XmlElement("Concept", typeof(Concept), Namespace = "http:https://openiz.org/model")]
[XmlElement("ConceptSet", typeof(ConceptSet), Namespace = "http:https://openiz.org/model")]
[XmlElement("ConceptRelationship", typeof(ConceptRelationship), Namespace = "http:https://openiz.org/model")]
[XmlElement("AssigningAuthority", typeof(AssigningAuthority), Namespace = "http:https://openiz.org/model")]
[XmlElement("ConceptClass", typeof(ConceptClass), Namespace = "http:https://openiz.org/model")]
[XmlElement("SecurityPolicy", typeof(SecurityPolicy), Namespace = "http:https://openiz.org/model")]
[XmlElement("SecurityRole", typeof(SecurityRole), Namespace = "http:https://openiz.org/model")]
[XmlElement("SecurityUser", typeof(SecurityUser), Namespace = "http:https://openiz.org/model")]
[XmlElement("ExtensionType", typeof(ExtensionType), Namespace = "http:https://openiz.org/model")]
[XmlElement("CodeSystem", typeof(CodeSystem), Namespace = "http:https://openiz.org/model")]
[XmlElement("ReferenceTerm", typeof(ReferenceTerm), Namespace = "http:https://openiz.org/model")]
[XmlElement("IdentifierType", typeof(IdentifierType), Namespace = "http:https://openiz.org/model")]
[XmlElement("UserEntity", typeof(UserEntity), Namespace = "http:https://openiz.org/model")]
[XmlElement("Entity", typeof(Entity), Namespace = "http:https://openiz.org/model")]
[XmlElement("Organization", typeof(Organization), Namespace = "http:https://openiz.org/model")]
[XmlElement("Person", typeof(Person), Namespace = "http:https://openiz.org/model")]
[XmlElement("Provider", typeof(Provider), Namespace = "http:https://openiz.org/model")]
[XmlElement("Material", typeof(Material), Namespace = "http:https://openiz.org/model")]
[XmlElement("ManufacturedMaterial", typeof(ManufacturedMaterial), Namespace = "http:https://openiz.org/model")]
[XmlElement("Patient", typeof(Patient), Namespace = "http:https://openiz.org/model")]
[XmlElement("Place", typeof(Place), Namespace = "http:https://openiz.org/model")]
[XmlElement("Bundle", typeof(Bundle), Namespace = "http:https://openiz.org/model")]
[XmlElement("Act", typeof(Act), Namespace = "http:https://openiz.org/model")]
[XmlElement("SubstanceAdministration", typeof(SubstanceAdministration), Namespace = "http:https://openiz.org/model")]
[XmlElement("QuantityObservation", typeof(QuantityObservation), Namespace = "http:https://openiz.org/model")]
[XmlElement("CodedObservation", typeof(CodedObservation), Namespace = "http:https://openiz.org/model")]
[XmlElement("EntityIdentifier", typeof(EntityIdentifier), Namespace = "http:https://openiz.org/model")]
[XmlElement("TextObservation", typeof(TextObservation), Namespace = "http:https://openiz.org/model")]
[XmlElement("PatientEncounter", typeof(PatientEncounter), Namespace = "http:https://openiz.org/model")]
public IdentifiedData Element { get; set; }

/// <summary>
/// Gets or sets a value indicating whether errors should be ignored.
/// </summary>
/// <value><c>true</c> if errors should be ignored; otherwise, <c>false</c>.</value>
[XmlAttribute("skipIfError")]
public bool IgnoreErrors { get; set; }
}
}
44 changes: 44 additions & 0 deletions OpenIZAdmin.Services/Dataset/DataObsolete.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2016-2018 Mohawk College of Applied Arts and Technology
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* User: khannan
* Date: 2018-5-7
*/

using System.Xml.Serialization;

namespace OpenIZAdmin.Services.Dataset
{
/// <summary>
/// Represents a data obsolete action.
/// </summary>
/// <seealso cref="OpenIZAdmin.Services.Dataset.DataInstallAction" />
[XmlType(nameof(DataObsolete), Namespace = "http:https://openiz.org/data")]
public class DataObsolete : DataInstallAction
{
/// <summary>
/// Initializes a new instance of the <see cref="DataObsolete"/> class.
/// </summary>
public DataObsolete()
{
}

/// <summary>
/// Gets the name of the action.
/// </summary>
/// <value>The name of the action.</value>
public override string ActionName => "Obsolete";
}
}
51 changes: 51 additions & 0 deletions OpenIZAdmin.Services/Dataset/DataUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2016-2018 Mohawk College of Applied Arts and Technology
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* User: khannan
* Date: 2018-5-7
*/

using System.Xml.Serialization;

namespace OpenIZAdmin.Services.Dataset
{
/// <summary>
/// Represents a data update action.
/// </summary>
/// <seealso cref="OpenIZAdmin.Services.Dataset.DataInstallAction" />
[XmlType(nameof(DataUpdate), Namespace = "http:https://openiz.org/data")]
public class DataUpdate : DataInstallAction
{
/// <summary>
/// Initializes a new instance of the <see cref="DataUpdate"/> class.
/// </summary>
public DataUpdate()
{
}

/// <summary>
/// Gets the name of the action.
/// </summary>
/// <value>The name of the action.</value>
public override string ActionName => "Update";

/// <summary>
/// Gets or sets a value indicating whether the instance should be inserted if it doesn't exist.
/// </summary>
/// <value><c>true</c> if the instance should be inserted if it doesn't exist; otherwise, <c>false</c>.</value>
[XmlAttribute("insertIfNotExists")]
public bool InsertIfNotExists { get; set; }
}
}
80 changes: 80 additions & 0 deletions OpenIZAdmin.Services/Dataset/DatasetInstall.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright 2016-2018 Mohawk College of Applied Arts and Technology
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* User: khannan
* Date: 2018-5-7
*/

using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;

namespace OpenIZAdmin.Services.Dataset
{
/// <summary>
/// Represents a dataset.
/// </summary>
[XmlRoot("dataset", Namespace = "http:https://openiz.org/data")]
[XmlType(nameof(DatasetInstall), Namespace = "http:https://openiz.org/data")]
public class DatasetInstall
{
/// <summary>
/// Initializes a new instance of the <see cref="DatasetInstall"/> class.
/// </summary>
public DatasetInstall()
{
this.Action = new List<DataInstallAction>();
}

/// <summary>
/// Initializes a new instance of the <see cref="DatasetInstall"/> class.
/// </summary>
/// <param name="id">The identifier.</param>
public DatasetInstall(string id) : this()
{
this.Id = id;
}

/// <summary>
/// Gets or sets the action.
/// </summary>
/// <value>The action.</value>
[XmlElement("insert", Type = typeof(DataInsert))]
[XmlElement("obsolete", Type = typeof(DataObsolete))]
[XmlElement("update", Type = typeof(DataUpdate))]
public List<DataInstallAction> Action { get; set; }

/// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>The identifier.</value>
[XmlAttribute("id")]
public string Id { get; set; }

/// <summary>
/// Loads the specified file to dataset.
/// </summary>
/// <param name="datasetFile">The dataset file.</param>
/// <returns>Returns the loaded dataset.</returns>
public static DatasetInstall Load(string datasetFile)
{
using (var fs = File.OpenRead(datasetFile))
{
var xs = new XmlSerializer(typeof(DatasetInstall));
return xs.Deserialize(fs) as DatasetInstall;
}
}
}
}
6 changes: 6 additions & 0 deletions OpenIZAdmin.Services/OpenIZAdmin.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
<Compile Include="Applets\AppletService.cs" />
<Compile Include="Applets\IAppletService.cs" />
<Compile Include="Auditing\AuditService.cs" />
<Compile Include="Dataset\DataAssociation.cs" />
<Compile Include="Dataset\DataInsert.cs" />
<Compile Include="Dataset\DataInstallAction.cs" />
<Compile Include="Dataset\DataObsolete.cs" />
<Compile Include="Dataset\DatasetInstall.cs" />
<Compile Include="Dataset\DataUpdate.cs" />
<Compile Include="Entities\EntityService.cs" />
<Compile Include="Core\ImsiServiceBase.cs" />
<Compile Include="Core\AmiServiceBase.cs" />
Expand Down

0 comments on commit e5cf2aa

Please sign in to comment.