I need to generate the XML in the TISS standard of ANS.
I have taken the available schemas in the site / a>, and by xsd2Code
generated the classes of tissV3_03_02.
I instantiated an object of type ctm_guiaLote
and now I need to generate an XML of that object.
I'm trying to do this:
XmlSerializer xmlSerializer = new XmlSerializer(typeof(ctm_guiaLote));
System.IO.Stream stream = new System.IO.FileStream("F:\GuiaTeste.xml", System.IO.FileMode.Create);
xmlSerializer.Serialize(stream, lote.getlote());
stream.Close();
I'm having the following exception, among others:
Exception: Thrown: "The TISS.ItemChoiceType1 type does not have the 'Item' enumeration value for the 'Item' element of the namespace ''." (System.InvalidOperationException) The System.InvalidOperationException was thrown: "The TISS.ItemChoiceType1 type does not have the 'Item' enumeration value for the 'Item' element of the namespace ''." Time: 7/31/2017 12:21:03 Thread: [4416]
And several others like this:
"Error while reflecting Type / Property"
Exception: Thrown: "Error while reflecting 'Item' property." (System.InvalidOperationException) A System.InvalidOperationException was thrown: "Error while reflecting 'Item' property." Time: 7/31/2017 12:21:03 Thread: [4416]
Class ctm_guyLote:
public partial class ctm_guiaLote
{
private string numeroLoteField;
private ctm_guiaLoteGuiasTISS guiasTISSField;
public ctm_guiaLote()
{
this.guiasTISSField = new ctm_guiaLoteGuiasTISS();
}
public string numeroLote
{
get
{
return this.numeroLoteField;
}
set
{
this.numeroLoteField = value;
}
}
public ctm_guiaLoteGuiasTISS guiasTISS
{
get
{
return this.guiasTISSField;
}
set
{
this.guiasTISSField = value;
}
}
}
class ctm_guiaLoteGuidesTISS:
[XmlInclude(typeof(ctm_spsadtGuia))]
public partial class ctm_guiaLoteGuiasTISS
{
private List<object> itemsField;
public ctm_guiaLoteGuiasTISS()
{
this.itemsField = new List<object>();
}
public List<object> Items
{
get
{
return this.itemsField;
}
set
{
this.itemsField = value;
}
}
}
GetLote () code:
public ctm_guiaLote getlote()
{
ctm_guiaLote lote = new ctm_guiaLote();
lote.numeroLote = "1";
lote.guiasTISS = new ctm_guiaLoteGuiasTISS();
List<object> guias = new List<object>();
ctm_spsadtGuia guia = new ctm_spsadtGuia();
guia.cabecalhoGuia.registroANS = "1";
guia.cabecalhoGuia.numeroGuiaPrestador = "1";
guia.dadosAtendimento.indicacaoAcidente = dm_indicadorAcidente.Item0;
guia.dadosAtendimento.tipoConsulta = dm_tipoConsulta.Item1;
guia.dadosSolicitacao.caraterAtendimento = dm_caraterAtendimento.Item1;
guia.dadosSolicitacao.dataSolicitacao = DateTime.Now;
guia.dadosSolicitacao.indicacaoClinica = "Teste";
guia.dadosExecutante.CNES = "123";
guia.dadosExecutante.contratadoExecutante.ItemElementName = ItemChoiceType1.cnpjContratado;
guia.dadosExecutante.contratadoExecutante.Item = "11111111111111";
guia.dadosExecutante.contratadoExecutante.nomeContratado = "Contratado";
guia.dadosSolicitante.contratadoSolicitante.nomeContratado = "Solicitante";
guia.dadosSolicitante.contratadoSolicitante.ItemElementName = ItemChoiceType1.cpfContratado;
guia.dadosSolicitante.contratadoSolicitante.Item = "11111111111";
guia.dadosAutorizacao.dataAutorizacao = DateTime.Now;
guia.dadosAutorizacao.numeroGuiaOperadora = "2";
guia.dadosAutorizacao.senha = "54321";
guia.dadosBeneficiario.atendimentoRN = dm_simNao.N;
guia.dadosBeneficiario.nomeBeneficiario = "Paciente";
guia.dadosBeneficiario.numeroCarteira = "9999";
guia.dadosBeneficiario.numeroCNS = "12345678901234";
guia.procedimentosExecutados.Add(new ct_procedimentoExecutadoSadt() { dataExecucao = DateTime.Now, procedimento = new ct_procedimentoDados() { codigoProcedimento = "1", codigoTabela= dm_tabela.Item22, descricaoProcedimento = "Consulta" } });
guias.Add(guia);
lote.guiasTISS.Items = guias;
return lote;
}
Anyone who can help with these exceptions, thank you.